Closed jansupol closed 7 years ago
@glassfishrobot Commented Reported by arunvc
@glassfishrobot Commented @m0mus said: According to the spec, number values in json document represented without quotes. If quotes are there it's a string value. This is why you have a binding exception. I see a problem here in the exception type. I suppose that JsonbException has to be thrown here, not NumberFormatException.
@glassfishrobot Commented @m0mus said: This issue is more related to Yasson (RI) than the spec. I created the corresponding issue on Yasson issues tracker: https://github.com/eclipse/yasson/issues/3 and closing it here.
@glassfishrobot Commented This issue was imported from java.net JIRA JSONB_SPEC-43
@glassfishrobot Commented Marked as invalid on Thursday, December 15th 2016, 3:49:44 am
From json to Object throws number format error if numeric field value is supplied in empty quotes.
for example in the front end JSON.stringify(products) converts the json to empty quoted string
in the server side , this code throws numberformat error jsonb.fromJson("
{"id":"","productName":"test"}
", Product.class);
java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:592) at java.lang.Integer.parseInt(Integer.java:615) at org.eclipse.persistence.json.bind.internal.serializer.IntegerTypeDeserializer.lambda$deserialize$58(IntegerTypeDeserializer.java:34) at java.util.Optional.orElseGet(Optional.java:267) at org.eclipse.persistence.json.bind.internal.serializer.IntegerTypeDeserializer.deserialize(IntegerTypeDeserializer.java:34) at org.eclipse.persistence.json.bind.internal.serializer.IntegerTypeDeserializer.deserialize(IntegerTypeDeserializer.java:25) at org.eclipse.persistence.json.bind.internal.serializer.AbstractValueTypeDeserializer.deserialize(AbstractValueTypeDeserializer.java:61) at org.eclipse.persistence.json.bind.internal.unmarshaller.ObjectDeserializer.deserializeNext(ObjectDeserializer.java:142) at org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractContainerDeserializer.deserializeInternal(AbstractContainerDeserializer.java:74) at org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractContainerDeserializer.deserialize(AbstractContainerDeserializer.java:55) at org.eclipse.persistence.json.bind.internal.unmarshaller.CollectionDeserializer.deserializeNext(CollectionDeserializer.java:118) at org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractContainerDeserializer.deserializeInternal(AbstractContainerDeserializer.java:74) at org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractContainerDeserializer.deserialize(AbstractContainerDeserializer.java:55) at org.eclipse.persistence.json.bind.internal.Unmarshaller.deserializeItem(Unmarshaller.java:57) at org.eclipse.persistence.json.bind.internal.Unmarshaller.deserialize(Unmarshaller.java:50)
Environment
jsonb-r-1.0-SNAPSHOT java8 ubuntu
Affected Versions
[1.0]