erlang - problems with converting to json -
i'm trying convert json via jiffy , exception, seem correct
{"purchaseorder", [{"purchaseordernumber","99503"}, {"orderdate","1999-10-20"}, {"address", [[{"type","shipping"}, {"name",[{<<"#text">>,"ellen adams"}]}, {"street",[{<<"#text">>,"123 maple street"}]}, {"city",[{<<"#text">>,"mill valley"}]}, {"state",[{<<"#text">>,"ca"}]}, {"zip",[{<<"#text">>,"10999"}]}, {"country",[{<<"#text">>,"usa"}]}], [{"type","billing"}, {"name",[{<<"#text">>,"tai yee"}]}, {"street",[{<<"#text">>,"8 oak avenue"}]}, {"city",[{<<"#text">>,"old town"}]}, {"state",[{<<"#text">>,"pa"}]}, {"zip",[{<<"#text">>,"95819"}]}, {"country",[{<<"#text">>,"usa"}]}]]}, {"deliverynotes", [{<<"#text">>,"please leave packages in shed driveway."}]}, {"items", [{"item", [[{"partnumber","872-aa"}, {"productname",[{<<"#text">>,"lawnmower"}]}, {"quantity",[{<<"#text">>,"1"}]}, {"usprice",[{<<"#text">>,"148.95"}]}, {"comment",[{<<"#text">>,"confirm electric"}]}], [{"partnumber","926-aa"}, {"productname",[{<<"#text">>,"baby monitor"}]}, {"quantity",[{<<"#text">>,"2"}]}, {"usprice",[{<<"#text">>,"39.98"}]}, {"shipdate",[{<<"#text">>,"1999-05-21"}]}]]}]}]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
help please, what's wrong?
- put proplists/objects in tuple
instead of [{a,b}]
should {[{a,b}]}
- use binary strings instead of lists
instead of "string"
should <<"string">>
- rtfm on jiffy data format: https://github.com/davisp/jiffy#data-format
example:
{[{<<"purchaseorder">>, {[{<<"purchaseordernumber">>,<<"99503">>}, {<<"orderdate">>,<<"1999-10-20">>}, {<<"address">>, [{[{<<"type">>,<<"shipping">>}, {<<"name">>,{[{<<"#text">>,<<"ellen adams">>}]}}, {<<"street">>,{[{<<"#text">>,<<"123 maple street">>}]}}, {<<"city">>,{[{<<"#text">>,<<"mill valley">>}]}}, {<<"state">>,{[{<<"#text">>,<<"ca">>}]}}, {<<"zip">>,{[{<<"#text">>,<<"10999">>}]}}, {<<"country">>,{[{<<"#text">>,<<"usa">>}]}}]}, {[{<<"type">>,<<"billing">>}, {<<"name">>,{[{<<"#text">>,<<"tai yee">>}]}}, {<<"street">>,{[{<<"#text">>,<<"8 oak avenue">>}]}}, {<<"city">>,{[{<<"#text">>,<<"old town">>}]}}, {<<"state">>,{[{<<"#text">>,<<"pa">>}]}}, {<<"zip">>,{[{<<"#text">>,<<"95819">>}]}}, {<<"country">>,{[{<<"#text">>,<<"usa">>}]}}]}]}, {<<"deliverynotes">>, {[{<<"#text">>,<<"please leave packages in shed driveway.">>}]}}, {<<"items">>, {[{<<"item">>, [{[{<<"partnumber">>,<<"872-aa">>}, {<<"productname">>,{[{<<"#text">>,<<"lawnmower">>}]}}, {<<"quantity">>,{[{<<"#text">>,<<"1">>}]}}, {<<"usprice">>,{[{<<"#text">>,<<"148.95">>}]}}, {<<"comment">>,{[{<<"#text">>,<<"confirm electric">>}]}}]}, {[{<<"partnumber">>,<<"926-aa">>}, {<<"productname">>,{[{<<"#text">>,<<"baby monitor">>}]}}, {<<"quantity">>,{[{<<"#text">>,<<"2">>}]}}, {<<"usprice">>,{[{<<"#text">>,<<"39.98">>}]}}, {<<"shipdate">>,{[{<<"#text">>,<<"1999-05-21">>}]}}]}]}]}}]}}]}
Comments
Post a Comment