maxurl / dict / JSON question

John J.A. Jannone's icon

Hello Max folk,

I'm trig to get the hang of using maxurl and dict to download data in JSON format.

I can get the following into a dict (attached), but I can't seem to extract the "requested_information" into another dict -- i've tried dict.unpack, dict.iter, but there's something I'm not understanding...

Some basic pointers would be much appreciated!

Thanks,

John

response1.txt
txt
Jazer Giles's icon

Hi John,

I don't know if there are vanilla dict objects that can accomplish this, but it can be done using JavaScript (see attached files).

Cheers,
Jazer

JSdict.maxpat
Max Patch
jgss.dict1_.js
js
John J.A. Jannone's icon

Jazer, This is great, thank you!

Where do you think the Japanese character encoding is getting stripped out?

Maybe in the JSON.stringify() ?

-John

Jazer Giles's icon

The Japanese characters were already broken in the text you posted and I simply copied and pasted that into the dict. Regardless, I'm fairly sure you won't be able to preserve the Japanese font within the dict....perhaps you could change them back to Japanese characters upon retrieval?

Jazer Giles's icon

Hey John,
Have a look at Menubar->Extras->ExamplesOvervew. In the "Interface" box, there's a patch called Unicode_Tips_for_Japanese....probably something in there that'll help

John J.A. Jannone's icon

Great thanks!

Jazer Giles's icon

Also, it worth noting that someone who is better at JS would probably know how to write this directly into another dictionary within JS. My hack-job of turning it into a string and then deserializing outside of JS was all I could come up with given my limited chops :)