mochijson2

Decode JSON with mochijson2 in Erlang

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...

Erlang : JSON List to JSON List

I have a list of JSON objects (received from a nosql db) and want to remove or rename some keys. And then I want to return data as a list of JSON objects once again. This Stackoverflow post provides a good sense of how to use mochijson2. And I'm thinking I could use a list comprehension to go through the list of JSON objects. The par...

Erlang : Tuple List into JSON

I have a list of tuples which are http headers. I want to convert the list to a JSON object. I try mochijson2 but to no avail. So I have the following : [{'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}, {'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.7"}, {'Accept-Encoding',"gzip,deflate"}, {'Accept-La...