How to parse a list of elements in JSON individually using route
hello.
* trying other methods
instead using js parser, I am using dict, maxurl, dct.unpack
my reply below is the new inquiry.
Hello.
I have been looking for a solution using dict to parse json.
The multiple lists is under "result", each list has "seq"
I'd like to parse into each dictionary with its queries.
If I get rid of "result", only thefirst list comes out.
or, should I create json with replacing "result" with each "seq"?
How to parse multiple obj output dict?
result obj:dictionary:u833004823 obj:dictionary:u759004824 obj:dictionary:u470004825
the json comes like this,
{
"result" : [ {
"seq" : "2",
"query" : "2601:801:201:7c50:d450:1f9:e918:2e15",
"status" : "success",
"country" : "United States",
"countrycode" : "US",
"region" : "CA",
"regionname" : "California",
"city" : "Sacramento",
"zip" : "94203",
"lat" : "38.5816",
"lon" : "-121.494",
"timezone" : "America/Los_Angeles",
"isp" : "Comcast Cable Communications, LLC",
"org" : "Comcast Cable Communications, LLC",
"toas" : "AS7922 COMCAST-7922 - Comcast Cable Communications, LLC",
"cdate" : "2020-02-23 16:54:27"
}
, {
"seq" : "1",
"query" : "",
"status" : "",
"country" : "",
"countrycode" : "",
"region" : "",
"regionname" : "",
"city" : "",
"zip" : "",
"lat" : "",
"lon" : "",
"timezone" : "",
"isp" : "",
"org" : "",
"toas" : "",
"cdate" : "2020-02-23 16:53:05"
}
]
}
This is the simplest way that crossed my mind:
How do you want to group them?
It worked! I used pack and they are printed in each groups.
I need to insert each group from print to each row of jit.cellblock
How to divide them into separate lists at least?
Thank you for the help!
I can use 'getsize result' to know how many lists there are.
Found it.
t b l
counter
join
coll
If you want to display data in cellblock, you can go this way:
A bit clunkier, but still doable. Max is not the best tool to display tabular data. If you want to actually use the data for some interactive/audio/visual processes, it may be easier.
Thank you!
Following up KLSDIZ's example, I have a weird issue that the dict.iter only can process maximum 11 elements in the list, rest of it cause error with "doesn't understand".
I find there's nothing wrong with the incoming list. Any solution to this?
Fixed using get message to dict directly.
Hi there, could you share your patch maybe for me to see how you did it? Thanks!
You may be interested in JS script I once made: https://cycling74.com/forums/sharing-parsing-dictionaries-from-maxurl