|
View previous topic :: View next topic |
Author |
Message |
menno
Joined: 21 May 2010 Posts: 157
|
Posted: Fri May 12, 2023 6:06 am Post subject: problem getting json value |
|
|
Hi support
I am builing a test that gets the info from a json reply
The http request result in this output
http get command gives :
Code: |
{"code":0,"msg":"success","time":"1683896070","data":{"degrees":{"celsius":{"time":"1683892112","unit":"","value":"6"}}}}
|
readable output is:
Code: |
{
"code":0,
"msg":"success",
"time":"1683892176",
"data":
{
"degrees":
{
"celsius":
{
"time":"1683892112",
"unit":"",
"value":"6"
}
}
}
}
|
i am interessted only in the "value":"6" line and then in this case / example the 6
We just want to check is the value is not below 1 and not higher as 10
i tried to use this help but i did not manage to get it working
https://www.ks-soft.net/cgi-bin/phpBB/viewtopic.php?t=8333&highlight=json
i played with the Tune up reply value but didn't succeed.
i tried : [('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)]
I hope you can help me out here.
many thanks in advance
m |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri May 12, 2023 10:45 am Post subject: |
|
|
1) HostMonitor version?
2) Test method? URL?
3) Where did you find %data% variable?
There is %HttpPage% variable, %SuggestedReply% variable.
Quote: | {"code":0,"msg":"success","time":"1683896070","data":{"degrees":{"celsius":{"time":"1683892112","unit":"","value":"6"}}}}
i am interessted only in the "value":"6" line and then in this case / example the 6
[('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)] |
4) There are no spaces, no CR, LF characters in this JSON string so entire string looks to "getword" operator as just 1 word
5) getnumber may help. But why did you set "getnumber 1"? I though you want to get 4th number, not first.
So if you want to set Warning or Normal test status you may try expression like
("%HttpPage%" getnumber 4 > 0) and ("%HttpPage%" getnumber 4 < 11)
Quote: | i played with the Tune up reply value but didn't succeed.
i tried : [('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)] |
I am confised. If you want to check value, then you want to do something depending on the value, right? Then I should ask why do you use this expression in TuneUpReply option?
Either you should use different expression and set some reply... or you should use different options like "Set Warning status if ...".
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
menno
Joined: 21 May 2010 Posts: 157
|
Posted: Fri May 12, 2023 11:09 am Post subject: |
|
|
Thx Alex !
for your info :
-HM version 13.50
-Test method : URL test ( also tried HTTP )
The solution you provided is good enough so i will use that.
Again many Thanks
m |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri May 12, 2023 12:05 pm Post subject: |
|
|
You are welcome
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|