Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/JSON/Erlang/json.erl
Normal file
41
Task/JSON/Erlang/json.erl
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
-module(json).
|
||||
-export([main/0]).
|
||||
|
||||
main() ->
|
||||
JSON =
|
||||
"{
|
||||
\"firstName\": \"John\",
|
||||
\"lastName\": \"Smith\",
|
||||
\"age\": 25,
|
||||
\"address\": {
|
||||
\"streetAddress\": \"21 2nd Street\",
|
||||
\"city\": \"New York\",
|
||||
\"state\": \"NY\",
|
||||
\"postalCode\": \"10021\"
|
||||
},
|
||||
\"phoneNumber\": [
|
||||
{
|
||||
\"type\": \"home\",
|
||||
\"number\": \"212 555-1234\"
|
||||
},
|
||||
{
|
||||
\"type\": \"fax\",
|
||||
\"number\": \"646 555-4567\"
|
||||
}
|
||||
]
|
||||
}",
|
||||
Erlang =
|
||||
{struct,
|
||||
[{"firstName","John"},
|
||||
{"lastName","Smith"},
|
||||
{"age",25},
|
||||
{"address",
|
||||
{struct,[{"streetAddress","21 2nd Street"},
|
||||
{"city","New York"},
|
||||
{"state","NY"},
|
||||
{"postalCode","10021"}]}},
|
||||
{"phoneNumber",
|
||||
{array,[{struct,[{"type","home"},{"number","212 555-1234"}]},
|
||||
{struct,[{"type","fax"},{"number","646 555-4567"}]}]}}]},
|
||||
io:format("JSON -> Erlang\n~p\n",[mochijson:decode(JSON)]),
|
||||
io:format("Erlang -> JSON\n~s\n",[mochijson:encode(Erlang)]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue