JSONParse, return object name(s)

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

JSONParse, return object name(s)

Post by Grovkillen » Fri Jan 21, 2022 8:44 am

If I could get the object name instead of blank value when using the * to look for a value I could use that to parse further down. Currently I need to know the structure and hardcode it.

Code: Select all


Let>temp=%SPACE%{"test":{"1":["a","b","c"],"2":["x","y","z"],"11":["aa","bb","cc"]}}
Trim>temp,temp
JSONParse>temp,$['test'][*],temp2

//i get this:
/*
temp2_count=3
temp2_1=
temp2_2=
temp2_3=
*/

//want this instead:
/*
temp2_count=3
temp2_1=1
temp2_2=2
temp2_3=11
*/
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: JSONParse, return object name(s)

Post by Grovkillen » Fri Jan 21, 2022 9:02 am

And using multiple * makes things a bit hard as well. This is just an suggestion. Don't know if it would break anything.

Code: Select all


Let>temp=%SPACE%{"test":{"1":["a","b","c"],"2":["x","y","z"],"11":["aa","bb","cc"]}}
Trim>temp,temp
JSONParse>temp,$['test'][*][*],temp2

//i get this:
/*
temp2_count=9
temp2_1=a
temp2_2=b
temp2_3=c
temp2_4=x
temp2_5=y
temp2_6=z
temp2_7=aa
temp2_8=bb
temp2_9=cc
*/

//want this:
/*
temp2_count=9
temp2_1=a
temp2_1_object=1
temp2_2=b
temp2_2_object=1
temp2_3=c
temp2_3_object=1
temp2_4=x
temp2_4_object=2
temp2_5=y
temp2_5_object=2
temp2_6=z
temp2_6_object=2
temp2_7=aa
temp2_7_object=11
temp2_8=bb
temp2_8_object=11
temp2_9=cc
temp2_9_object=11
*/
Let>ME=%Script%

Running: 15.0.24
version history

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