Questions tagged [mochijson2]
7 questions
8
votes
1 answer
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"},
…

Ben Ahlan
- 497
- 6
- 9
5
votes
5 answers
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…

Jon Romero
- 4,062
- 6
- 36
- 34
2
votes
1 answer
Erlang Design Advice regarding HTTP services
I'm new to Erlang but I would like to get started with an application which feels applicable to the technology due to the concurrency desires I have.
This picture highlights what i want to do.
http://imagebin.org/163917
Where messages are pulled…

Dave
- 21
- 1
2
votes
2 answers
Correctly parsing single element JSON lists in Erlang [Mochijson]?
Decoding JSON lists using Mochijson produces erroneous results depending on the list values.
For example:
Eshell V5.9.1 (abort with ^G)
1> c(mochijson).
{ok,mochijson}
2> mochijson:decode("[]").
{array,[]}
3>…

user2640025
- 21
- 1
1
vote
3 answers
How to pattern match structures returned by mochijson2?
I've just started tinkering with Erlang and am building a very simple test web application which is just intended to show my twitter timeline.
I'm using webmachine to write the app and erlyDTL to render the templates.
My question is related to the…

peeb
- 11
- 2
0
votes
1 answer
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…

Ben Ahlan
- 497
- 6
- 9
0
votes
1 answer
mochijson2 decode chinese has error exception throw: invalid_utf8
mochijson2:decode(<<"{\"strKey\":\"中国\", \"intKey\":10, \"arrayKey\":[1, 2, 3]}">>).
** exception throw: invalid_utf8
in function mochijson2:tokenize_string_fast/2 (src/mochijson2.erl, line 424)
in call from mochijson2:tokenize_string/2…

user3766493
- 13
- 3