aarondav / protobuf-java-format

Automatically exported from code.google.com/p/protobuf-java-format
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

JsonFormat.merge does not parse doubles correctly for undefined field #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a JSON string with field Foo that has a double as a key
2. use JsonFormat.merge with a Builder that does not have Foo defined

What is the expected output? What do you see instead?
The call to JsonFormat.merge fails with a message like:
Parseexception: 1:14: Couldn't parse integer: For input string: "0.95"

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.
Defining Foo as a double in the protobuf is a workaround, but I think it would 
be better if support for double was added to handleMissingField()

Original issue reported on code.google.com by bmwchic...@gmail.com on 12 Sep 2012 at 8:44

GoogleCodeExporter commented 9 years ago
This is similar to the TextFormat spec. I think that the assumption was, at 
least with the TextFormat spec was that its better to error on bad fields when 
people are typing things, then when machines are making things into bytes. This 
way mistyping something does not cause unexpected behavior. This makes the 
TextFormat a little more brittle for future compatibility, but still should 
work for backwards compatibility. Maybe there should be some option for 
JsonFormat to not act like TextFormat, and to be less brittle and allow unknown 
fields?

Original comment by came...@indeed.com on 9 Aug 2013 at 3:14