yaws-json2 is encoder/decoder taked from Yaws webserver.
In rebar.config:
{yaws_json2, ".*", {git, "git://github.com/myua/yaws-json2", {tag, "master"}}}
Use yaws_json2:decode_string/1
to decode json. Example of input json:
{
first_name: "John",
last_name: "Smith",
enabled: true,
phone_number: 937600131,
avatar: {
origin: "default.png",
thumbnails: [
"default_min.png"
]
}
}
Output:
{ok, {struct, [
{"first_name", "John"},
{"last_name", "Smith"},
{"enabled", true},
{"phone_number", 937600131},
{"avatar", {struct, [
{"origin", "default.png"},
{"thumbnails", {array, [
"default_min.png"
]}}
]}}
]}}
And also use yaws_json2:encode/1
to encode json.