jansupol / jsonbapi

0 stars 0 forks source link

numberformat error while converting empty string json to Integer #43

Closed jansupol closed 7 years ago

jansupol commented 7 years ago

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]

jansupol commented 6 years ago
jansupol commented 7 years ago

@glassfishrobot Commented Reported by arunvc

jansupol commented 7 years ago

@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.

jansupol commented 7 years ago

@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.

jansupol commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JSONB_SPEC-43

jansupol commented 7 years ago

@glassfishrobot Commented Marked as invalid on Thursday, December 15th 2016, 3:49:44 am