Ben mochiweb kullanıyorum ve karmaşık veri yapısı ile uğraşmak için json kodlayıcısını nasıl kullanacağımı bilmiyorum. Mochijson ve mochijson2 arasındaki farklar nelerdir? İyi bir örnek var mı? Dizilerin olarak ikili, listeleri gibi dizeleri ile çalışır ve yalnızca UTF-8 kodunu çözer mochijson2Erlang? Da veri yapısını kodlamak için mochijson nasıl kullanılır?
46> T6={struct,[{hello,"asdf"},{from,"1"},{to,{a,"aa"}}]}.
{struct,[{hello,"asdf"},{from,"1"},{to,{a,"aa"}}]}
47> mochijson2:encode(T6).
** exception exit: {json_encode,{bad_term,{a,"aa"}}}
in function mochijson2:json_encode/2
in call from mochijson2:'-json_encode_proplist/2-fun-0-'/3
in call from lists:foldl/3
in call from mochijson2:json_encode_proplist/2
39> T3={struct,[{hello,"asdf"},{[{from,"1"},{to,"2"}]}]}.
{struct,[{hello,"asdf"},{[{from,"1"},{to,"2"}]}]}
40> mochijson:encode(T3).
** exception error: no function clause matching mochijson:'-json_encode_proplist/2-fun-0-'({[{from,"1"},{to,"2"}]},
[44,"\"asdf\"",58,"\"hello\"",123],
{encoder,unicode,null})
in function lists:foldl/3
in call from mochijson:json_encode_proplist/2