JSONParse Issue

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
OrangeAndBlue
Newbie
Posts: 18
Joined: Thu Feb 06, 2014 5:19 pm

JSONParse Issue

Post by OrangeAndBlue » Fri Apr 24, 2015 4:39 pm

I'm having trouble with handling a JSON response. I've verified response syntax is properly formatted to standard.

Post:

Code: Select all

HTTPRequest>xxx,,POST,yyy,sResult
Return:

Code: Select all

{"srvhead":{"ixncode":"MuAgent.AddEvent","ixnstat":"OK","errtext":"","errno":0,"getcnt":0,"inscnt":1,"updcnt":0,"delcnt":0,"iudcnt":0,"subcnt":0,"keylist":""}}

Code: Select all

0: SRESULT={"srvhead":{"ixncode":"MuAgent.AddEvent","ixnstat":"OK","errtext":"","errno":0,"getcnt":0,"inscnt":1,"updcnt":0,"delcnt":0,"iudcnt":0,"subcnt":0,"keylist":""}}
Attempt to read:

Code: Select all

JSONParse>%sResult%,ixnstat,r
Result:
ERROR: Line XX: not appropriate
Access violation at address..... [some null reference]
I also can't perform any operations on that string variable holding the response. Could anyone provide some help with this issue? Thank you!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: JSONParse Issue

Post by Marcus Tettmar » Wed Apr 29, 2015 1:58 pm

Hi,

ixnstat belongs to member srvhead. Your json contains srvhead which is itself a json structure which contains child member ixnstat.

So you actually want to request srvhead.ixnstat.

Try this:

Code: Select all

JSONParse>%sResult%,srvhead.ixnstat,r
An example which works in isolation:

Code: Select all

/*
json:
{"srvhead":{"ixncode":"MuAgent.AddEvent","ixnstat":"OK","errtext":"","errno":0,"getcnt":0,"inscnt":1,"updcnt":0,"delcnt":0,"iudcnt":0,"subcnt":0,"keylist":""}}
*/
 
LabelToVar>json,sResult
JSONParse>%sResult%,srvhead.ixnstat,r
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

OrangeAndBlue
Newbie
Posts: 18
Joined: Thu Feb 06, 2014 5:19 pm

Re: JSONParse Issue

Post by OrangeAndBlue » Wed Apr 29, 2015 2:31 pm

Thanks Marcus

I actually found the root of my problem was due to the way JSON is formatted conflicting with MS's complex expressions.

By setting DISABLE_COMPLEX_EXPRESSIONS whenever dealing with the JSON, I can properly interpret the response.

Thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts