Skip to content

Commit 9787ddf

Browse files
Fix wrong-documentation about spec handling of range numeric values in JSON format.
Fixes protocolbuffers/protobuf#24772 PiperOrigin-RevId: 844709301
1 parent aec68c3 commit 9787ddf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

content/programming-guides/json.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,14 @@ possible.
274274
## Out of range numeric values
275275

276276
When parsing a numeric value, if the number that is is parsed from the wire
277-
doesn't fit in the corresponding type, the parser should coerce the value to the
278-
appropriate type. This has the same behavior as a simple cast in C++ or Java
279-
(for example, if a number larger than 2^32 is read as for an int32 field, it
280-
will be truncated to 32 bits).
277+
doesn't fit in the corresponding type, the parser should fail to parse.
278+
279+
This includes any negative number for `uint32`, and numbers less than `INT_MIN`
280+
or larger than `INT_MAX` for `int32`.
281+
282+
Values with nonzero fractional portions are not allowed for integer-typed
283+
fields. Zero fractional portions are accepted. For example `1.0` is valid for an
284+
int32 field, but `1.5` is not.
281285

282286
## ProtoJSON Wire Safety {#json-wire-safety}
283287

0 commit comments

Comments
 (0)