Decode JSON with mochijson2 in Erlang

Posted by Jon Romero on Stack Overflow See other posts from Stack Overflow or by Jon Romero
Published on 2010-04-29T17:19:27Z Indexed on 2010/04/29 20:17 UTC
Read the original article Hit count: 288

Filed under:
|
|
|

I have a var that has some JSON data:

A = <<"{\"job\": {\"id\": \"1\"}}">>. 

Using mochijson2, I decode the data:

 Struct = mochijson2:decode(A). 

And now I have this:

{struct,[{<<"job">>,{struct,[{<<"id">>,<<"1">>}]}}]}

I am trying to read (for example), "job" or "id".

I tried using struct.get_value but it doesn't seem to work.

Any ideas?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about mochiweb