I have json string that has some keys with spaces. The following works because the key has no spaces (Sym1):
JSONParse>HTMLResponse,dataset.ZoneYC.Sym1,theHigh
The following errors with access violation with key having spaces (NQ - NQ11)
JSONParse>HTMLResponse,dataset.ZoneYC.NQ - NQ11,theHigh
I also tried these formats:
JSONParse>HTMLResponse,dataset.ZoneYC['NQ - NQ11'],theHigh
JSONParse>HTMLResponse,dataset.ZoneYC['"NQ - NQ11"'],theHigh
JSONParse>HTMLResponse,dataset.ZoneYC["NQ - NQ11"],theHigh
Is there a way to for JSONParse to read json strings with keys containing spaces?
Thank you,
Gerry
jsonparse with Spaces in Keys
Moderators: Dorian (MJT support), JRL
Re: jsonparse with Spaces in Keys
Using the JSONParse> sample from help and changing the "clients" key to "all clients", I can confirm that JSONParse> fails with an Access Violation error if there is a space in the key name. Sounds like something will need to be fixed to be able to use spaces.
Code: Select all
/*
MyJSON:
{ "uid" : "1234",
"all clients" : ["client1","client2","client3"],
"people" : [{"Name":"Marcus","Age":"21"},{"Name":"Dorian","Age":"18"}],
"color" : "red",
"size" : 14 }
*/
LabelToVar>MyJSON,sJSON
JSONParse>sJSON,uid,result
JSONParse>sJSON,all clients,result
JSONParse>sJSON,all clients[1],result
JSONParse>sJSON,people[1].Name,result
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: jsonparse with Spaces in Keys
Thanks for this. Will look into it.
In the mean time a workaround would be to use StringReplace on the JSON string to change the items with spaces to e.g. underscores.
In the mean time a workaround would be to use StringReplace on the JSON string to change the items with spaces to e.g. underscores.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?