Hello,

I am using java protocol buffers' JsonFormat class to convert a JSON to a 
proto object. After adding a new field of type float I forgot to recompile 
the proto file to the java file. In this case, my understanding is that the 
new field should be considered an unknown field. However, the 
handleMissingField method does not correctly handle unknown fields of type 
float/double: tokenizer.lookingAtInteger() method returns true because the 
string (eg: 1.71) begins with a digit, but the conversion to integer 
obviously fail:

com.googlecode.protobuf.format.JsonFormat$ParseException: 1:38: Couldn't 
parse integer: For input string: "1.71"
    at 
com.googlecode.protobuf.format.JsonFormat$Tokenizer.parseException(JsonFormat.java:765)
    at 
com.googlecode.protobuf.format.JsonFormat$Tokenizer.integerParseException(JsonFormat.java:783)
*    at 
com.googlecode.protobuf.format.JsonFormat$Tokenizer.consumeInt64(JsonFormat.java:624)
*
*     at 
com.googlecode.protobuf.format.JsonFormat.handleMissingField(JsonFormat.java:986)
*
    at 
com.googlecode.protobuf.format.JsonFormat.mergeField(JsonFormat.java:936)
    at 
com.googlecode.protobuf.format.JsonFormat.mergeField(JsonFormat.java:958)
    at com.googlecode.protobuf.format.JsonFormat.merge(JsonFormat.java:870)
    at com.googlecode.protobuf.format.JsonFormat.merge(JsonFormat.java:818)
    at 
com.tora.g2.core.datastructure.gds.codec.PBGDSCodec.encode(PBGDSCodec.java:63)

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to