|
@@ -109,6 +109,23 @@ next(Level = [Next | Nexts], Buf, Opt) ->
|
|
value(null, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "null">>, Opt);
|
|
value(null, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "null">>, Opt);
|
|
value(false, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "false">>, Opt);
|
|
value(false, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "false">>, Opt);
|
|
value(true, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "true">>, Opt);
|
|
value(true, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "true">>, Opt);
|
|
|
|
+value({json, T}, Nexts, Buf, Opt) ->
|
|
|
|
+ try
|
|
|
|
+ next(Nexts, <<Buf/binary, (iolist_to_binary(T))/binary>>, Opt)
|
|
|
|
+ catch
|
|
|
|
+ error:badarg ->
|
|
|
|
+ ?ERROR(value, [{json, T}, Nexts, Buf, Opt])
|
|
|
|
+ end;
|
|
|
|
+value({json_utf8, T}, Nexts, Buf, Opt) ->
|
|
|
|
+ try unicode:characters_to_binary(T) of
|
|
|
|
+ {error, OK, Invalid} ->
|
|
|
|
+ {error, {{invalid_json_utf8, OK, Invalid}, [{?MODULE, value, [{json_utf8, T}, Nexts, Buf, Opt], [{line, ?LINE}]}]}};
|
|
|
|
+ B when is_binary(B) ->
|
|
|
|
+ next(Nexts, <<Buf/binary, B/binary>>, Opt)
|
|
|
|
+ catch
|
|
|
|
+ error:badarg ->
|
|
|
|
+ ?ERROR(value, [{json_utf8, T}, Nexts, Buf, Opt])
|
|
|
|
+ end;
|
|
value(Value, Nexts, Buf, Opt) when is_integer(Value) -> next(Nexts, <<Buf/binary, (integer_to_binary(Value))/binary>>, Opt);
|
|
value(Value, Nexts, Buf, Opt) when is_integer(Value) -> next(Nexts, <<Buf/binary, (integer_to_binary(Value))/binary>>, Opt);
|
|
value(Value, Nexts, Buf, Opt) when is_float(Value) -> next(Nexts, <<Buf/binary, (float_to_binary(Value, Opt?OPT.float_format))/binary>>, Opt);
|
|
value(Value, Nexts, Buf, Opt) when is_float(Value) -> next(Nexts, <<Buf/binary, (float_to_binary(Value, Opt?OPT.float_format))/binary>>, Opt);
|
|
value(Value, Nexts, Buf, Opt) when ?IS_STR(Value) -> string(Value, Nexts, Buf, Opt);
|
|
value(Value, Nexts, Buf, Opt) when ?IS_STR(Value) -> string(Value, Nexts, Buf, Opt);
|