From ea958784877936c55c1cd3ce5dc3c349f80c7612 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Fri, 13 Sep 2024 13:44:08 +0200 Subject: [PATCH] fixup! Let `json:decode/3` keep whitespaces --- lib/stdlib/src/json.erl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/stdlib/src/json.erl b/lib/stdlib/src/json.erl index 68f9dbbdbac6..fc2dd04a4c77 100644 --- a/lib/stdlib/src/json.erl +++ b/lib/stdlib/src/json.erl @@ -1386,18 +1386,19 @@ object_key(_, Original, Skip, Acc, Stack, Decode) -> continue(<>, Original, Skip, Acc, Stack0, Decode, Value) -> case Stack0 of - [] -> terminate(Rest, Rest, Acc, Value); + [] -> terminate(Rest, Original, Skip, Acc, Value); [?ARRAY | _] -> array_push(Rest, Original, Skip, Acc, Stack0, Decode, Value); [?OBJECT | _] -> object_value(Rest, Original, Skip, Acc, Stack0, Decode, Value); [Key | Stack] -> object_push(Rest, Original, Skip, Acc, Stack, Decode, Value, Key) end. -terminate(<>, Original, Acc, Value) when ?is_ws(Byte) -> - terminate(Rest, Original, Acc, Value); -terminate(<<>>, _, Acc, Value) -> +terminate(<>, Original, Skip, Acc, Value) when ?is_ws(Byte) -> + terminate(Rest, Original, Skip, Acc, Value); +terminate(<<>>, _, _Skip, Acc, Value) -> {Value, Acc, <<>>}; -terminate(<<_/bits>>, Original, Acc, Value) -> - {Value, Acc, Original}. +terminate(<<_/bits>>, Original, Skip, Acc, Value) -> + <<_:Skip/binary, Rest/binary>> = Original, + {Value, Acc, Rest}. -spec unexpected_utf8(binary(), non_neg_integer()) -> no_return(). unexpected_utf8(Original, Skip) when byte_size(Original) =:= Skip ->