step1.
download the mochijson2 lib.
step2.
set the http header
content_type("application/json"),
step3.
write the io steam as json.
io:format(mochijson2({struct,[{"id",id},{"name",name}]})).
step4.
we can see the return data is
{id:id,name:name}