diff --git a/README.md b/README.md index ac1d1e2..0bda564 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ that - [`prettify/1`](#prettify1) - [`is_json/1,2`](#is_json12) - [`is_term/1,2`](#is_term12) + - [`maps_support/0`](#maps_support0) * [callback exports](#callback_exports) - [`Module:init/1`](#moduleinit1) - [`Module:handle_event/2`](#modulehandle_event2) @@ -609,6 +610,17 @@ returns true if input is a valid erlang representation of json, false if not what exactly constitutes valid json may be altered via [options](#option) + +#### `maps_support/0` #### + +```erlang +maps_support() -> true | false +``` + +if **jsx** was compiled with map support enabled returns `true`, else +`false` + + ## callback exports ## the following functions should be exported from a **jsx** callback module diff --git a/src/jsx.erl b/src/jsx.erl index b2405c3..5448921 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -28,6 +28,7 @@ -export([format/1, format/2, minify/1, prettify/1]). -export([encoder/3, decoder/3, parser/3]). -export([resume/3]). +-export([maps_support/0]). -export_type([json_term/0, json_text/0, token/0]). -export_type([encoder/0, decoder/0, parser/0, internal_state/0]). @@ -161,6 +162,15 @@ resume(Term, {parser, State, Handler, Stack}, Config) -> jsx_parser:resume(Term, State, Handler, Stack, jsx_config:parse_config(Config)). +-spec maps_support() -> true | false. + +-ifndef(maps_support). +maps_support() -> false. +-endif. +-ifdef(maps_support). +maps_support() -> true. +-endif. + -ifdef(TEST).