mochiweb

JSON-encode a list using mochiweb

I need to JSON-encode a list using mochiweb. How do I get the following: List = ["This is message 1.", "This is message 2.", "This is the last message"] mochijson2:encode({struct,[{messages,list_to_binary(List)}] to produce this bit of JSON: {"messages":"["This is message 1.","This is message 2.","This is the last message"]} ...

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