{"id":13435039,"url":"https://github.com/talentdeficit/jsx","last_synced_at":"2025-05-14T09:09:12.118Z","repository":{"id":920218,"uuid":"684090","full_name":"talentdeficit/jsx","owner":"talentdeficit","description":"an erlang application for consuming, producing and manipulating json. inspired by yajl","archived":false,"fork":false,"pushed_at":"2024-06-26T15:39:01.000Z","size":2375,"stargazers_count":695,"open_issues_count":24,"forks_count":219,"subscribers_count":38,"default_branch":"main","last_synced_at":"2025-03-31T15:54:11.976Z","etag":null,"topics":["erlang","json"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/talentdeficit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-05-24T21:56:24.000Z","updated_at":"2025-03-21T03:48:01.000Z","dependencies_parsed_at":"2024-11-05T23:02:18.317Z","dependency_job_id":"63ee7787-50a2-41bf-9ed7-745cefb4ce62","html_url":"https://github.com/talentdeficit/jsx","commit_stats":{"total_commits":1083,"total_committers":43,"mean_commits":"25.186046511627907","dds":0.07663896583564178,"last_synced_commit":"1d3407aa9752430ec0a06111ac1b046ffafdca22"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentdeficit%2Fjsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentdeficit%2Fjsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentdeficit%2Fjsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talentdeficit%2Fjsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talentdeficit","download_url":"https://codeload.github.com/talentdeficit/jsx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247962605,"owners_count":21024871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","json"],"created_at":"2024-07-31T03:00:31.134Z","updated_at":"2025-04-09T02:18:07.962Z","avatar_url":"https://github.com/talentdeficit.png","language":"Erlang","funding_links":[],"categories":["JSON","Text and Numbers","Libraries"],"sub_categories":["JSON"],"readme":"# jsx (v3.0.0) #\n\n\nan erlang application for consuming, producing and manipulating [json][json]. \ninspired by [yajl][yajl]\n\n**jsx** is built via [rebar3][rebar3]\n\ncurrent status: ![](https://github.com/talentdeficit/jsx/workflows/EUnit/badge.svg)\n\n**jsx** is released under the terms of the [MIT][MIT] license\n\ncopyright 2010-2016 alisdair sullivan\n\n## index ##\n\n* [quickstart](#quickstart)\n* [description](#description)\n  - [migrating from 1.x](#migrating)\n  - [json \u003c-\u003e erlang mapping](#json---erlang-mapping)\n  - [incomplete input](#incomplete-input)\n* [data types](#data-types)\n  - [`json_term()`](#json_term)\n  - [`json_text()`](#json_text)\n  - [`event()`](#event)\n  - [`option()`](#option)\n* [exports](#exports)\n  - [`encoder/3`, `decoder/3` \u0026 `parser/3`](#encoder3-decoder3--parser3)\n  - [`decode/1,2`](#decode12)\n  - [`encode/1,2`](#encode12)\n  - [`format/1,2`](#format12)\n  - [`minify/1`](#minify1)\n  - [`prettify/1`](#prettify1)\n  - [`is_json/1,2`](#is_json12)\n  - [`is_term/1,2`](#is_term12)\n* [callback exports](#callback_exports)\n  - [`Module:init/1`](#moduleinit1)\n  - [`Module:handle_event/2`](#modulehandle_event2)\n* [acknowledgements](#acknowledgements)\n\n\n## quickstart ##\n\n#### to add to a rebar3 project ####\nAdd to `rebar.config`\n```erlang\n...\n{erl_opts, [debug_info]}.\n{deps, [\n       ...\n       {jsx, \"~\u003e 3.0\"}\n]}.\n...\n```\n\n#### to build the library and run tests ####\n\n```bash\n$ rebar3 compile\n$ rebar3 eunit\n```\n\n#### to convert a utf8 binary containing a json string into an erlang term ####\n\n```erlang\n1\u003e jsx:decode(\u003c\u003c\"{\\\"library\\\": \\\"jsx\\\", \\\"awesome\\\": true}\"\u003e\u003e, []).\n#{\u003c\u003c\"awesome\"\u003e\u003e =\u003e true,\u003c\u003c\"library\"\u003e\u003e =\u003e \u003c\u003c\"jsx\"\u003e\u003e}\n2\u003e jsx:decode(\u003c\u003c\"{\\\"library\\\": \\\"jsx\\\", \\\"awesome\\\": true}\"\u003e\u003e, [{return_maps, false}]).\n[{\u003c\u003c\"library\"\u003e\u003e,\u003c\u003c\"jsx\"\u003e\u003e},{\u003c\u003c\"awesome\"\u003e\u003e,true}]\n3\u003e jsx:decode(\u003c\u003c\"[\\\"a\\\",\\\"list\\\",\\\"of\\\",\\\"words\\\"]\"\u003e\u003e).\n[\u003c\u003c\"a\"\u003e\u003e, \u003c\u003c\"list\"\u003e\u003e, \u003c\u003c\"of\"\u003e\u003e, \u003c\u003c\"words\"\u003e\u003e]\n```\n\n#### to convert an erlang term into a utf8 binary containing a json string ####\n\n```erlang\n1\u003e jsx:encode(#{\u003c\u003c\"library\"\u003e\u003e =\u003e \u003c\u003c\"jsx\"\u003e\u003e, \u003c\u003c\"awesome\"\u003e\u003e =\u003e true}).\n\u003c\u003c\"{\\\"awesome\\\":true,\\\"library\\\":\\\"jsx\\\"}\"\u003e\u003e\n2\u003e jsx:encode([{\u003c\u003c\"library\"\u003e\u003e,\u003c\u003c\"jsx\"\u003e\u003e},{\u003c\u003c\"awesome\"\u003e\u003e,true}]).\n\u003c\u003c\"{\\\"library\\\": \\\"jsx\\\", \\\"awesome\\\": true}\"\u003e\u003e\n3\u003e jsx:encode([\u003c\u003c\"a\"\u003e\u003e, \u003c\u003c\"list\"\u003e\u003e, \u003c\u003c\"of\"\u003e\u003e, \u003c\u003c\"words\"\u003e\u003e]).\n\u003c\u003c\"[\\\"a\\\",\\\"list\\\",\\\"of\\\",\\\"words\\\"]\"\u003e\u003e\n```\n\n#### to check if a binary or a term is valid json ####\n\n```erlang\n1\u003e jsx:is_json(\u003c\u003c\"[\\\"this is json\\\"]\"\u003e\u003e).\ntrue\n2\u003e jsx:is_json(\"[\\\"this is not\\\"]\").\nfalse\n3\u003e jsx:is_term([\u003c\u003c\"this is a term\"\u003e\u003e]).\ntrue\n4\u003e jsx:is_term([this, is, not]).\nfalse\n```\n\n#### to minify some json ####\n\n```erlang\n1\u003e jsx:minify(\u003c\u003c\"{\n  \\\"a list\\\": [\n    1,\n    2,\n    3\n  ]\n}\"\u003e\u003e).\n\u003c\u003c\"{\\\"a list\\\":[1,2,3]}\"\u003e\u003e\n```\n\n#### to prettify some json ####\n\n```erlang\n1\u003e jsx:prettify(\u003c\u003c\"{\\\"a list\\\":[1,2,3]}\"\u003e\u003e).\n\u003c\u003c\"{\n  \\\"a list\\\": [\n    1,\n    2,\n    3\n  ]\n}\"\u003e\u003e\n```\n\n## description ##\n\n\n**jsx** is an erlang application for consuming, producing and manipulating \n[json][json]\n\n**jsx** follows the json [spec][rfc4627] as closely as possible with allowances for\nreal world usage\n\n**jsx** is pragmatic. the json spec allows extensions so **jsx** extends the spec in a\nnumber of ways. see the section on `strict` in [options](#option) below though\n\njson has no official comments but this parser allows c/c++ style comments. \nanywhere whitespace is allowed you can insert comments (both `// ...` and `/* ... */`)\n\nsome particularly irresponsible json emitters leave trailing commas at the end of\nobjects or arrays. **jsx** allows a single trailing comma in input. multiple commas\nin any position or a preceding comma are still errors\n\nall **jsx** decoder input should be `utf8` encoded binaries. sometimes you get binaries\nthat are almost but not quite valid utf8 whether due to improper escaping or poor\nencoding. **jsx** replaces invalid codepoints and poorly formed sequences with the \nunicode replacement character (`u+FFFD`) but does it's best to return something\ncomprehensible\n\njson only allows keys and strings to be delimited by double quotes (`u+0022`) but\njavascript allows them to be delimited by single quotes (`u+0027`) as well. **jsx**\nfollows javascript in this. strings that start with single quotes can contain double\nquotes but must end with single quotes and must escape any single quotes they contain\n\njson and **jsx** only recognize escape sequences as outlined in the json spec. it just\nignores bad escape sequences leaving them in strings unaltered\n\n### json \u0026lt;-\u003e erlang mapping ###\n\n**json**                        | **erlang**\n--------------------------------|--------------------------------\n`number`                        | `integer()` and `float()`\n`string`                        | `binary()` and `atom()`\n`true`, `false` and `null`      | `true`, `false` and `null`\n`array`                         | `[]` and `[JSON]`\n`object`                        | `#{}`, `[{}]` and `[{binary() OR atom() OR integer(), JSON}]`\nsee below                       | `datetime()`\n\n*   numbers\n\n    javascript and thus json represent all numeric values with floats. there's no\n    reason for erlang -- a language that supports arbitrarily large integers -- to\n    restrict all numbers to the ieee754 range\n    \n    whenever possible, **jsx** will interpret json numbers that look like integers as \n    integers. other numbers will be converted  to erlang's floating point type, which\n    is nearly but not quite iee754. negative zero is not representable in erlang (zero\n    is unsigned in erlang and `0` is equivalent to `-0`) and will be interpreted as\n    regular zero. numbers not representable are beyond the concern of this implementation,\n    and will result in parsing errors\n\n    when converting from erlang to json, floats are represented with their \n    shortest representation that will round trip without loss of precision. this \n    means that some floats may be superficially dissimilar (although \n    functionally equivalent). for example, `1.0000000000000001` will be \n    represented by `1.0`\n\n*   strings\n\n    json strings must be unicode encoded binaries or erlang atoms. in practice,\n    because **jsx** only accepts `utf8` binaries all binary strings must be `utf8`.\n    in addition to being unicode json strings restrict a number of codepoints and\n    define a number of escape sequences\n\n    json string escapes of the form `\\uXXXX` will be converted to their \n    equivalent codepoints during parsing. this means control characters and \n    other codepoints disallowed by the json spec may be encountered in resulting \n    strings. the utf8 restriction means the surrogates are explicitly disallowed.\n    if a string contains escaped surrogates (`u+d800` to `u+dfff`) they are\n    interpreted but only when they form valid surrogate pairs. surrogates\n    encountered otherwise are replaced with the replacement codepoint (`u+fffd`)\n\n    all erlang strings are represented by **valid** `utf8` encoded binaries. the \n    encoder will check strings for conformance. badly formed `utf8` sequences may\n    be replaced with the replacement codepoint (`u+fffd`) according to the unicode\n    spec\n\n    this implementation performs no normalization on strings beyond that \n    detailed here. be careful when comparing strings as equivalent strings \n    may have different `utf8` encodings\n\n*   true, false and null\n\n    the json primitives `true`, `false` and `null` are represented by the \n    erlang atoms `true`, `false` and `null`. surprise\n\n*   arrays\n\n    json arrays are represented with erlang lists of json values as described \n    in this section\n\n*   objects\n\n    json objects are represented by erlang maps.    \n\n*   datetime\n\n    erlang datetime tuples (`{{Year, Month, Day}, {Hour, Min, Sec}}`) as returned\n    from `erlang:localtime/0` are automatically encoded as [iso8601][iso8601]\n    strings and are assumed to be UTC time. no conversion is attempted of json [iso8601][iso8601] strings in decoded json\n\n\n### incomplete input ###\n\n**jsx** can handle incomplete json texts. if the option `stream` is passed to the decoder\nor parser and if a partial json text is parsed, rather than returning a term from\nyour callback handler, **jsx** returns `{incomplete, F}` where  `F` is a function with \nan identical API to the anonymous fun returned from `decoder/3`, `encoder/3` or \n`parser/3`. it retains the internal state of the  parser at the point where input\nwas exhausted. this allows you to parse as you stream json over a socket or file \ndescriptor, or to parse large json texts without needing to keep them entirely in\nmemory\n\nhowever, it is important to recognize that **jsx** is conservative by default. **jsx** will \nnot consider the parsing complete even when input is exhausted and the json text is\nunambiguously incomplete. to end parsing call the `incomplete` function with the\nargument `end_stream` (or `end_json`) like:\n\n```erlang\n1\u003e {incomplete, F} = jsx:decode(\u003c\u003c\"[\"\u003e\u003e, [stream]).\n{incomplete,#Fun\u003cjsx_decoder.1.122947756\u003e}\n2\u003e F(end_stream).  % can also be `F(end_json)`\n** exception error: bad argument\n3\u003e {incomplete, G} = F(\u003c\u003c\"]\"\u003e\u003e).\n{incomplete,#Fun\u003cjsx_decoder.1.122947756\u003e}\n4\u003e G(end_stream).  % can also be `G(end_json)`\n[]\n```\n\n\n## data types ##\n\n#### `json_term()` ####\n\n```erlang\njson_term() = [json_term()]\n    | [{binary() | atom() | integer(), json_term()}]\n    | #{} % map of any size, not just the empty map\n    | true\n    | false\n    | null\n    | integer()\n    | float()\n    | binary()\n    | atom()\n\t\t| datetime()\n```\n\nthe erlang representation of json. binaries should be `utf8` encoded, or close \nat least\n\n#### `json_text()` ####\n\n```erlang\njson_text() = binary()\n```\n\na utf8 encoded binary containing a json string\n\n#### `event()` ####\n\n```erlang\nevent() = start_object\n    | end_object\n    | start_array\n    | end_array\n    | {key, binary()}\n    | {string, binary()}\n    | {integer, integer()}\n    | {float, float()}\n    | {literal, true}\n    | {literal, false}\n    | {literal, null}\n    | end_json\n```\n\nthe subset of [`token()`](#token) emitted by the decoder and encoder to handlers\n\n#### `option()` ####\n\n```erlang\noption() = dirty_strings\n    | escaped_forward_slashes\n    | escaped_strings\n    | repeat_keys\n    | stream\n    | strict\n    | {strict, [strict_option()]}\n    | return_tail\n    | uescape\n    | unescaped_jsonp\n\nstrict_option() = comments\n    | trailing_commas\n    | utf8\n    | single_quotes\n    | escapes\n``` \n\n**jsx** functions all take a common set of options. not all flags have meaning \nin all contexts, but they are always valid options. functions may have \nadditional options beyond these. see \n[individual function documentation](#exports) for details\n\n- `dirty_strings`\n\n    json escaping is lossy; it mutates the json string and repeated application \n    can result in unwanted behaviour. if your strings are already escaped (or \n    you'd like to force invalid strings into \"json\" you monster) use this flag \n    to bypass escaping. this can also be used to read in **really** invalid json \n    strings. everything between unescaped quotes are passed as is to the resulting \n    string term. note that this takes precedence over any other options\n\n- `escaped_forward_slashes`\n\n    json strings are escaped according to the json spec. this means forward \n    slashes (solidus) are only escaped when this flag is present. otherwise they \n    are left unescaped. you may want to use this if you are embedding json \n    directly into a html or xml document\n\n- `escaped_strings`\n\n    by default both the encoder and decoder return strings as utf8 binaries \n    appropriate for use in erlang. escape sequences that were present in decoded \n    terms are converted into the appropriate codepoint while encoded terms are \n    unaltered. this flag escapes strings as if for output in json, removing \n    control codes and problematic codepoints and replacing them with the \n    appropriate escapes\n\n- `stream`\n\n    see [incomplete input](#incomplete-input)\n\n- `strict`\n\n    as mentioned [earlier](#description), **jsx** is pragmatic. if you're more of a\n    json purist or you're really into bdsm stricter adherence to the spec is\n    possible. the following restrictions are available\n    \n    * `comments`\n    \n        comments are disabled and result in a `badarg` error\n    \n    * `trailing_commas`\n    \n        trailing commas in an object or list result in `badarg` errors\n    \n    * `utf8`\n    \n        invalid codepoints and malformed unicode result in `badarg` errors\n\n    * `single_quotes`\n    \n        only keys and strings delimited by double quotes (`u+0022`) are allowed. the\n        single quote (`u+0027`) results in a `badarg` error\n    \n    * `escapes`\n\n        escape sequences not adhering to the json spec result in a `badarg` error\n    \n    * `control_codes`\n\n        control codes in strings result in `badarg` errors\n\n    any combination of these can be passed to **jsx** by using `{strict, [strict_option()]}`.\n    `strict` is equivalent to `{strict, [comments, trailing_commas, utf8, single_quotes, escapes, control_codes]}`\n\n- `return_tail`\n\n    upon reaching the end of a valid json term in an input stream return the term and any\n    remaining bytes in the input stream as `{with_tail, term(), binary()}` where the second\n    member of the tuple is the json term and the third is any remaining bytes. note that\n    leading whitespace will be stripped from the tail\n\n- `uescape`\n\n    escape all codepoints outside the ascii range for 7 bit clean output. note\n    this escaping takes place even if no other string escaping is requested (via\n    `escaped_strings`)\n\n- `unescaped_jsonp`\n\n    javascript interpreters treat the codepoints `u+2028` and `u+2029` as \n    significant whitespace. json strings that contain either of these codepoints \n    will be parsed incorrectly by some javascript interpreters. by default, \n    these codepoints are escaped (to `\\u2028` and `\\u2029`, respectively) to \n    retain compatibility. this option simply removes that escaping\n\n\n## exports ##\n\n\n#### `encoder/3`, `decoder/3` \u0026 `parser/3` ####\n\n```erlang\ndecoder(Module, Args, Opts) -\u003e Fun((JSONText) -\u003e any())\nencoder(Module, Args, Opts) -\u003e Fun((JSONTerm) -\u003e any())\nparser(Module, Args, Opts) -\u003e Fun((Tokens) -\u003e any())\n\n  Module = atom()\n  Args = any()\n  Opts = [option()]\n  JSONText = json_text()\n  JSONTerm = json_term()\n  Tokens = event() | [event()]\n```\n\n**jsx** is a json compiler with interleaved tokenizing, syntactic analysis and \nsemantic analysis stages. included are two tokenizers; one that handles json \ntexts (`decoder/3`) and one that handles erlang terms (`encoder/3`). there is \nalso an entry point to the syntactic analysis stage for use with user-defined \ntokenizers (`parser/3`)\n\nall three functions return an anonymous function that takes the appropriate type \nof input and returns the result of performing semantic analysis, the tuple \n`{incomplete, F}` where `F` is a new anonymous function (see \n[incomplete input](#incomplete_input)) or a `badarg` error exception if \nsyntactic analysis fails\n\n`Module` is the name of the callback module\n\n`Args` is any term that will be passed to `Module:init/1` prior to syntactic \nanalysis to produce an initial state\n\n`Opts` are detailed [here](#option)\n\ncheck out [callback module documentation](#callback_exports) for details of \nthe callback module interface\n\n#### `decode/1,2` ####\n\n```erlang\ndecode(JSON) -\u003e Term\ndecode(JSON, Opts) -\u003e Term\n\n  JSON = json_text()\n  Term = json_term()\n  Opts = [option() | labels | {labels, Label} | return_maps]\n    Label = binary | atom | existing_atom | attempt_atom\n    F = fun((any()) -\u003e any())\n```\n\n`decode` parses a json text (a `utf8` encoded binary) and produces an erlang \nterm\n\nthe option `labels` controls how keys are converted from json to\nerlang terms.  `binary` (the default behavior) does no conversion\nbeyond normal escaping. `atom` converts keys to erlang atoms and\nresults in a `badarg` error if the keys fall outside the range of erlang\natoms. `existing_atom` is identical to `atom` except it will not add\nnew atoms to the atom table and will result in a `badarg` error if the atom\ndoes not exist. `attempt_atom` will convert keys to atoms when they exist,\nand leave them as binary otherwise\n\nthe option `{return_maps, false}` will return objects as proplists instead \nof maps.\n\nraises a `badarg` error exception if input is not valid json\n\n\n#### `encode/1,2` ####\n\n```erlang\nencode(Term) -\u003e JSON\nencode(Term, Opts) -\u003e JSON\n\n  Term = json_term()\n  JSON = json_text()\n  Opts = [option() | space | {space, N} | indent | {indent, N}]\n    N = pos_integer()\n```\n\n`encode` converts an erlang term into json text (a `utf8` encoded binary)\n\nthe option `{space, N}` inserts `N` spaces after every comma and colon in your \njson output. `space` is an alias for `{space, 1}`. the default is `{space, 0}`\n\nthe option `{indent, N}` inserts a newline and `N` spaces for each level of \nindentation in your json output. note that this overrides spaces inserted after \na comma. `indent` is an alias for `{indent, 1}`. the default is `{indent, 0}`\n\nraises a `badarg` error exception if input is not a valid \n[erlang representation of json](#json---erlang-mapping)\n\n\n#### `format/1,2` ####\n\n```erlang\nformat(JSON) -\u003e JSON\nformat(JSON, Opts) -\u003e JSON\n\n  JSON = json_text()\n  Opts = [option() | space | {space, N} | indent | {indent, N} | {newline, LF}]\n     N = pos_integer()\n    LF = binary()\n```\n\n`format` parses a json text (a `utf8` encoded binary) and produces a new json \ntext according to the format rules specified by `Opts`\n\nthe option `{space, N}` inserts `N` spaces after every comma and colon in your \njson output. `space` is an alias for `{space, 1}`. the default is `{space, 0}`\n\nthe option `{indent, N}` inserts a newline and `N` spaces for each level of \nindentation in your json output. note that this overrides spaces inserted after \na comma. `indent` is an alias for `{indent, 1}`. the default is `{indent, 0}`\n\nthe option `{newline, LF}` defines a custom newline symbol(s). \nthe default is `{newline, \u003c\u003c$\\n\u003e\u003e}`\n\nraises a `badarg` error exception if input is not valid json\n\n\n#### `minify/1` ####\n\n```erlang\nminify(JSON) -\u003e JSON\n\n  JSON = json_text()\n```\n\n`minify` parses a json text (a `utf8` encoded binary) and produces a new json \ntext stripped of whitespace\n\nraises a `badarg` error exception if input is not valid json\n\n\n#### `prettify/1` ####\n\n```erlang\nprettify(JSON) -\u003e JSON\n\n  JSON = json_text()\n```\n\n`prettify` parses a json text (a `utf8` encoded binary) and produces a new json \ntext equivalent to `format(JSON, [{space, 1}, {indent, 2}])`\n\nraises a `badarg` error exception if input is not valid json\n\n\n#### `is_json/1,2` ####\n\n```erlang\nis_json(MaybeJSON) -\u003e true | false\nis_json(MaybeJSON, Opts) -\u003e true | false\n\n  MaybeJSON = any()\n  Opts = options()\n```\n\nreturns true if input is a valid json text, false if not\n\nwhat exactly constitutes valid json may be [altered](#option)\n\n\n#### `is_term/1,2` ####\n\n```erlang\nis_term(MaybeJSON) -\u003e true | false\nis_term(MaybeJSON, Opts) -\u003e true | false\n\n  MaybeJSON = any()\n  Opts = options()\n```\n\nreturns true if input is a valid erlang representation of json, false if not\n\nwhat exactly constitutes valid json may be altered via [options](#option)\n\n## callback exports ##\n\nthe following functions should be exported from a **jsx** callback module\n\n#### `Module:init/1` ####\n\n```erlang\nModule:init(Args) -\u003e InitialState\n\n  Args = any()\n  InitialState = any()\n```\n\nwhenever any of `encoder/3`, `decoder/3` or `parser/3` are called, this function \nis called with the `Args` argument provided in the calling function to obtain \n`InitialState`\n\n#### `Module:handle_event/2` ####\n\n```erlang\nModule:handle_event(Event, State) -\u003e NewState\n\n  Event = [event()]\n  State = any()\n  NewState = any()\n```\n\nsemantic analysis is performed by repeatedly calling `handle_event/2` with a \nstream of events emitted by the tokenizer and the current state. the new state \nreturned is used as the input to the next call to `handle_event/2`. the \nfollowing events must be handled:\n\n-   `start_object`\n\n    the start of a json object\n\n-   '{key, binary()}'\n\n    the key of an entry in a json object\n\n-   `end_object`\n\n    the end of a json object\n\n-   `start_array`\n\n    the start of a json array\n\n-   `end_array`\n\n    the end of a json array\n\n-   `{string, binary()}`\n\n    a json string. it will usually be a `utf8` encoded binary. see the \n    [options](#option) for possible exceptions. note that keys are also\n    json strings\n\n-   `{integer, integer()}`\n\n    an erlang integer (bignum)\n\n-   `{float, float()}`\n\n    an erlang float\n\n-   `{literal, true}`\n\n    the atom `true`\n\n-   `{literal, false}`\n\n    the atom `false`\n\n-   `{literal, null}`\n\n    the atom `null`\n\n-   `end_json`\n\n    this event is emitted when syntactic analysis is completed. you should \n    do any cleanup and return the result of your semantic analysis\n\n\n## acknowledgements ##\n\njsx wouldn't be what it is without the contributions of [Paul J. Davis](https://github.com/davisp), [Lloyd Hilaiel](https://github.com/lloyd), [John Engelhart](https://github.com/johnezang), [Bob Ippolito](https://github.com/etrepum), [Brujo Benavides](https://github.com/elbrujohalcon), [Alex Kropivny](https://github.com/amtal), [Steve Strong](https://github.com/srstrong), [Michael Truog](https://github.com/okeuday), [Devin Torres](https://github.com/devinus), [fogfish](https://github.com/fogfish), [emptytea](https://github.com/emptytea), [John Daily](https://github.com/macintux), [Ola Bäckström](https://github.com/olabackstrom), [Joseph Crowe](https://github.com/JosephCrowe), [Patrick Gombert](https://github.com/patrickgombert), [Eshengazin S. Kuat](https://github.com/eskuat), [Max Lapshin](https://github.com/maxlapshin), [Bikram Chatterjee](https://github.com/c-bik), [Michael Uvarov](https://github.com/arcusfelis), [Led](https://github.com/Ledest) and [tvv](https://github.com/tvv)\n\n[json]: http://json.org\n[yajl]: http://lloyd.github.com/yajl\n[MIT]: http://www.opensource.org/licenses/mit-license.html\n[rebar3]: https://rebar3.org\n[meck]: https://github.com/eproxus/meck\n[rfc4627]: http://tools.ietf.org/html/rfc4627\n[travis]: https://travis-ci.org/\n[jsxn]: https://github.com/talentdeficit/jsxn\n[iso8601]: http://www.iso.org/iso/iso8601\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentdeficit%2Fjsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalentdeficit%2Fjsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentdeficit%2Fjsx/lists"}