Copyright © 2007 Mochi Media, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Authors: Bob Ippolito (bob@mochimedia.com).
Yet another JSON (RFC 4627) library for Erlang. mochijson2 works with binaries as strings, arrays as lists (without an {array, _}) wrapper and it only knows how to decode UTF-8 (and ASCII).
JSON terms are decoded as follows (javascript -> erlang):encoder_option() = handler_option() | utf8_option()
json_array() = [json_term()]
json_eep18_object() = {[{json_string(), json_term()}]}
json_iolist() = {json, iolist()}
json_number() = integer() | float()
json_object() = {struct, [{json_string(), json_term()}]}
json_string() = atom | binary()
json_term() = json_string() | json_number() | json_array() | json_object() | json_eep18_object() | json_iolist()
utf8_option() = boolean()
Emit unicode as utf8 (default - false)
decode/1 | Decode the given iolist to Erlang terms. |
decode/2 | Decode the given iolist to Erlang terms using the given object format for decoding, where proplist returns JSON objects as [{binary(), json_term()}] proplists, eep18 returns JSON objects as {[binary(), json_term()]}, map returns JSON objects as #{binary() => json_term()}, and struct returns them as-is. |
decoder/1 | Create a decoder/1 with the given options. |
encode/1 | Encode the given as JSON to an iolist. |
encoder/1 | Create an encoder/1 with the given options. |
decode(S::iolist()) -> json_term()
Decode the given iolist to Erlang terms.
decode(S::iolist(), Options::[{format, proplist | eep18 | struct | map}]) -> json_term()
Decode the given iolist to Erlang terms using the given object format for decoding, where proplist returns JSON objects as [{binary(), json_term()}] proplists, eep18 returns JSON objects as {[binary(), json_term()]}, map returns JSON objects as #{binary() => json_term()}, and struct returns them as-is.
decoder(Options::[decoder_option()]) -> function()
Create a decoder/1 with the given options.
encode(Any::json_term()) -> iolist()
Encode the given as JSON to an iolist.
encoder(Options::[encoder_option()]) -> function()
Create an encoder/1 with the given options.
Generated by EDoc