Json parser?

gwsounddsg's icon

I am receiving over udp an osc message with a json string:

{
"uniqueID": string,
"number": string
"name": string
"listName": string
"type": string
"colorName": string
"flagged": number
"armed": number
"cues": [ { }, { }, { } ]
}

Is there an abstraction or anything that will parse this? The keys will be static if that helps.

Thanks
GW

Emmanuel Jourdan's icon

You might have some chances with dict.deserialize.

mzed's icon
mzed's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is almost ok:

gwsounddsg's icon

dict.deserialize followed by dict.itter did the job!

Thanks
GW

bpcook's icon

How so? I have a similar JSON string and can't figure out how to parse it with dict.deserialize and dict.itter. Maybe I am just too tired to figure it out. Please post a patch if you don't mind.

Jan M's icon

another option would be to do the parsing in JavaScript directly using JSON.parse(your-json-string)

Philip's icon

Hi folks, hope it's not frowned upon here to revive a thread...
I seem to be having the same issue as bpcook and I was wondering if/how you solved it?

Cheers
pc

nicolasnuzillard's icon

just in case

function f (){
    var str =  '{ "name":"John", "age":31, "city":"New York" }';
    var res = JSON.parse(str);
     post(  res.name + '\n' );
    post(  res.age + '\n' );
    post(  res.city + '\n' );
}