View Source simdjson (simdjsone v0.4.2)
Fast decoding of JSON using simdjson C++ library.
By default JSON decoder uses the atom null
to represent JSON nulls. To modify this behavior, set the following configuration option to another atom value (e.g. nil
for Elixir):
{simdjsone, [{null, nil}]}.
See also https://github.com/simdjson/simdjson
Link to this section Summary
Functions
Decode a JSON string or binary to a term representation of JSON.
Decode a JSON string or binary to a term representation of JSON.
Encode a term to a JSON string.
Find a given Path
(which must start with a slash) in the JSON resource. The resource reference must have been previously created by calling parse/1,2
.
Find a given Path
(which must start with a slash) in the JSON resource. The resource reference must have been previously created by calling parse/1,2
.
Fast integer to binary conversion
Minify a JSON string or binary.
Parse a JSON string or binary and save it in a resource for later access by get/2
. Returns a resource reference owned by the calling pid.
Link to this section Types
-type decode_opt() :: return_maps | object_as_tuple | dedupe_keys | use_nil | {null_term, atom()}.
-type decode_opts() :: [decode_opt()].
Decode options:
return_maps
- decode JSON object as mapobject_as_tuple
- decode JSON object as a proplist wrapped in a tuplededup_keys
- eliminate duplicate keys from a JSON objectuse_nil
- decode JSON "null" asnil
{null_term, V}
- use the given valueV
for a JSON "null"
-type encode_opt() ::
uescape | pretty | force_utf8 | use_nil | escape_forward_slashes |
{bytes_per_red, non_neg_integer()}.
-type encode_opts() :: [encode_opt()].
Encode options:
uescape
- escape UTF-8 sequences to produce a 7-bit clean outputpretty
- return JSON using two-space indentationuse_nil
- encode the atomnil
asnull`</li> <li>`escape_fwd_slash
- escape the/
character (useful when encoding URLs){bytes_per_red, N}
- whereN
>= 0 - This controls the number of bytes that Jiffy will process as an equivalent to a reduction. Each 20 reductions we consume 1% of our allocated time slice for the current process. When the Erlang VM indicates we need to return from the NIF.
Link to this section Functions
-spec decode(binary() | list() | reference()) -> term().
Decode a JSON string or binary to a term representation of JSON.
-spec decode(binary() | list() | reference(), decode_opts()) -> term().
Decode a JSON string or binary to a term representation of JSON.
-spec encode(term()) -> iodata().
Encode a term to a JSON string.
-spec encode(term(), encode_opts()) -> iodata().
-spec get(reference(), binary()) -> term().
Find a given Path
(which must start with a slash) in the JSON resource. The resource reference must have been previously created by calling parse/1,2
.
-spec get(reference(), binary(), decode_opts()) -> term().
Find a given Path
(which must start with a slash) in the JSON resource. The resource reference must have been previously created by calling parse/1,2
.
-spec int_to_bin(integer()) -> binary().
Fast integer to binary conversion
-spec minify(binary() | list()) -> {ok, binary()} | {error, binary()}.
Minify a JSON string or binary.
-spec parse(binary()) -> reference().
Parse a JSON string or binary and save it in a resource for later access by get/2
. Returns a resource reference owned by the calling pid.