add maps_support/0 function that reports whether jsx was

compiled with maps support or not
This commit is contained in:
alisdair sullivan 2014-10-28 04:43:32 +00:00
parent bbf7d39e85
commit 6b333396a3
2 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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).