Skip to content

Latest commit

 

History

History
322 lines (150 loc) · 6.78 KB

jsf.md

File metadata and controls

322 lines (150 loc) · 6.78 KB

Module jsf

Functions for JSON to Erlang data conversion.

For most purposes, these functions are not called by code outside of
this library: Erlang client and Erlang server application code usually
have no need to use these functions.
== Links
  • http://www.erlang-projects.org/Public/news/ejson/view
  • http://www.erlang.org/eeps/eep-0018.html
  • http://www.erlang.org/ml-archive/erlang-questions/200511/msg00193.html
  • http://www.ietf.org/rfc/rfc4627.txt
  • http://www.json.org/
  • http://www.lshift.net/blog/2007/02/17/json-and-json-rpc-for-erlang
  • http://www.json.com/json-schema-proposal/
== JSON Basic Data Types
------
object
          {}
          { members }
members
          pair
          pair, members
pair
          string : value
array
         []
         [ elements ]
elements
         value
         value, elements
value
         string
         number
         object
         true (atom)
         false (atom)
         null (atom)
------
== Mapping: JSON -> Erlang Terms, using mochiweb
------
json::object() = {struct, [json::pair()]}
json::pair() = {string(), json::value()}
     string() = [byte()]
     byte() = integer()
json::array() = [json::value()]
json::value() = json::object() | json::array() | json::number() | json::string() | json::true() | json::false() | json::null()
json::number() = integer() | float()
json::string() = binary()
json::true() = true
json::false() = false
json::null() = null
------
== Mapping: UBF -> Erlang Terms
------
ubf::tuple() = tuple()
ubf::list() = list()
ubf::number = integer() | float()
ubf::string() = {\'$S\', [integer()]}
ubf::proplist() = {\'$P\', [{term(), term()}]}
ubf::binary() = binary()
ubf::true() = true
ubf::false() = false
ubf::undefined() = undefined
ubf::atom() = atom()
ubf::record() = record()
------
== Mapping: UBF value -> JSON value
------
ubf::tuple() = {struct, [{<<"$T">>, ubf::list()}]}
ubf::list() = [value()]
ubf::number() = integer() | float()
ubf::string() = {struct, [{<<"$S">>, binary()}]}
ubf::proplist() = {struct, [{binary(), value()}]}
ubf::binary() = binary()
ubf::true() = true
ubf::false() = false
ubf::undefined() = null
ubf::atom() = {struct, [{<<"$A">>, atomname()}]}
     atomname() = binary()  % a.k.a. list_to_binary(atom_to_list()) for the actual atom
ubf::record() = {struct, [{<<"$R">>, recordname()}] ++ [recordpair()]}
     recordname() = binary()  % a.k.a. list_to_binary(atom_to_list()) for the record\'s name
     recordpair() = {recordkey(), value()}
     recordkey() = binary()  % a.k.a. list_to_binary(atom_to_list()) for the record key\'s name
value() = ubf::tuple() | ubf::list() | ubf::number() | ubf::string() | ubf::binary() | ubf::true() | ubf::false() | ubf::undefined() | ubf::atom() | ubf::record()
------

. Behaviours: contract_proto.

Function Index

atom_to_binary/1
binary_to_atom/1
binary_to_existing_atom/1
contract_records/0
decode/1
decode/2
decode/3
decode_init/0
decode_init/1
decode_init/2
do_decode/2
do_decode/3
do_encode/2
encode/1
encode/2
proto_driver/0
proto_packet_type/0
proto_vsn/0

Function Details

atom_to_binary/1

atom_to_binary(X) -> any()

binary_to_atom/1

binary_to_atom(X) -> any()

binary_to_existing_atom/1

binary_to_existing_atom(X) -> any()

contract_records/0

contract_records() -> any()

decode/1

decode(X) -> any()

decode/2

decode(X, Mod) -> any()

decode/3

decode(X, Mod, State) -> any()

decode_init/0

decode_init() -> any()

decode_init/1

decode_init(Safe) -> any()

decode_init/2

decode_init(Safe, Binary) -> any()

do_decode/2

do_decode(X, Mod) -> any()

do_decode/3

do_decode(X, Mod, Safe) -> any()

do_encode/2

do_encode(X, Mod) -> any()

encode/1

encode(X) -> any()

encode/2

encode(X, Mod) -> any()

proto_driver/0

proto_driver() -> any()

proto_packet_type/0

proto_packet_type() -> any()

proto_vsn/0

proto_vsn() -> any()