Array length (size) with JSONParse

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Fred
Newbie
Posts: 18
Joined: Sat Aug 05, 2017 4:44 pm

Array length (size) with JSONParse

Post by Fred » Mon Apr 30, 2018 7:21 pm

Imagine, I have an array:

"result": {
"orders": Array[54][
{
"limit_speed": "0.02",
"alive": true,
"price": "0.0152",
"id": 1762041,
"type": 0,
"workers": 13,
"algo": 21,
"accepted_speed": "17.99093735"
},
{
"limit_speed": "0.02",
"alive": true,
"price": "0.0151",
"id": 1757084,
"type": 0,
"workers": 9,
"algo": 21,
"accepted_speed": "18.87724492"

......................................
......................................
......................................
Array truncated


Can I take a number of array elements (54) with JSONParse and assign it to a variable?

User avatar
PepsiHog
Automation Wizard
Posts: 511
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Array length (size) with JSONParse

Post by PepsiHog » Thu Jul 12, 2018 7:39 pm

Hello,

Isn't that exactly what the example in the help file is doing?

Code: Select all

/*

MyJSON:

{ "uid" : "1234", 

  "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,clients,result

JSONParse>sJSON,clients[1],result

JSONParse>sJSON,people[1].Name,result
I have never used Json command, but this example shows how to do what you are asking. Does it not?
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

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