Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
jsone
add-jsx-as-float_format-option.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File add-jsx-as-float_format-option.patch of Package jsone
From 5dcc715323f7a6a5bc2741e43791592e8c7df015 Mon Sep 17 00:00:00 2001 From: Led <ledest@gmail.com> Date: Fri, 9 Mar 2018 01:52:54 +0200 Subject: [PATCH] add 'jsx' as float_format option --- src/jsone.erl | 2 +- src/jsone_encode.erl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jsone.erl b/src/jsone.erl index 496a05d..e863ff9 100644 --- a/src/jsone.erl +++ b/src/jsone.erl @@ -195,7 +195,7 @@ -type encode_option() :: native_utf8 | native_forward_slash | canonical_form | - {float_format, [float_format_option()]} | + {float_format, [float_format_option()] | jsx} | {datetime_format, datetime_encode_format()} | {object_key_type, string | scalar | value} | {space, non_neg_integer()} | diff --git a/src/jsone_encode.erl b/src/jsone_encode.erl index e5aa940..5aa4b8f 100644 --- a/src/jsone_encode.erl +++ b/src/jsone_encode.erl @@ -65,7 +65,7 @@ native_utf8 = false :: boolean(), native_forward_slash = false :: boolean(), canonical_form = false :: boolean(), - float_format = [{scientific, 20}] :: [jsone:float_format_option()], + float_format = [{scientific, 20}] :: [jsone:float_format_option()] | jsx, datetime_format = {iso8601, 0} :: {jsone:datetime_format(), jsone:utc_offset_seconds()}, object_key_type = string :: string | scalar | value, space = 0 :: non_neg_integer(), @@ -151,6 +151,8 @@ 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{float_format = jsx} = Opt) when is_float(Value) -> + next(Nexts, <<Buf/binary, (list_to_binary(io_lib_format:fwrite_g(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_STR(Value) -> @@ -552,7 +554,7 @@ parse_option([native_forward_slash | T], Opt) -> parse_option(T, Opt?OPT{native_forward_slash = true}); parse_option([canonical_form | T], Opt) -> parse_option(T, Opt?OPT{canonical_form = true}); -parse_option([{float_format, F} | T], Opt) when is_list(F) -> +parse_option([{float_format, F}|T], Opt) when F =:= jsx; is_list(F) -> parse_option(T, Opt?OPT{float_format = F}); parse_option([{space, N} | T], Opt) when is_integer(N), N >= 0 -> parse_option(T, Opt?OPT{space = N}); -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor