Hi All,
Below is example.when the number value was convertted to E*,JSONSerializer
will hit this trouble.
when I use arraylist convert map to json and would like re-convert to map
object,this error often to occurs.
Do you have any idea to solve it?
My Povit version is 1.5.2
|--------------------------------------------------------------------------|
|double a=1.000005; |
|double b=0.000005; |
|System.out.println(a); |
|System.out.println(b); |
|String testStr1=JSONSerializer.toString(a); |
|String testStr2=JSONSerializer.toString(b); |
|System.out.println(testStr1); |
|System.out.println(testStr2); |
|try { |
| System.out.println(JSONSerializer.parseDouble(testStr1)); |
| System.out.println(JSONSerializer.parseDouble(testStr2)); |
|} catch (SerializationException e) { |
| // TODO Auto-generated catch block |
| e.printStackTrace(); |
|} |
|1.000005 |
|5.0E-6 |
|1.000005 |
|5.0E-6 |
|1.000005 |
|Exception in thread "main" java.lang.NumberFormatException: For input |
|string: "5.0E" |
| at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) |
| at java.lang.Double.parseDouble(Unknown Source) |
| at org.apache.pivot.json.JSONSerializer.readNumber( |
|JSONSerializer.java:403) |
| at org.apache.pivot.json.JSONSerializer.readValue( |
|JSONSerializer.java:219) |
| at org.apache.pivot.json.JSONSerializer.readObject( |
|JSONSerializer.java:193) |
| at org.apache.pivot.json.JSONSerializer.parse( |
|JSONSerializer.java:810) |
| at org.apache.pivot.json.JSONSerializer.parseDouble( |
|JSONSerializer.java:906) |
| at testing.JsonTest.main(JsonTest.java:23) |
|--------------------------------------------------------------------------|
Best regards,
Ken Jiang
*******************************************
Murata Electronics Trading (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:[email protected]
*******************************************