The company has developed a set of SIA services that encapsulate messaging and webservice services, enabling simplified communication between projects and no loss of message storage. It sends the message through a JSON string, and then converts the string into a Java object to communicate between projects.
Our project in this way for about half a year, accidentally found a bug, in order to solve this bug caused by another bug appeared. The following separately say two bugs, the previous one did not specifically find the reason, should also be the underlying implementation of the problem.
1. Using Jsonplugin-0.32.jar's Jsonutil.deserialize (str), the deserialize (STR) implemented in this jar is the value of the numeric type (the amount-a decimal number) transmitted in our message, And the number in the message is not in the form of a string, the number is passed between systems may become a scientific notation, at this time if the jar directly:
map<string, object> dataMap = (map<string,object>) jsonutil.deserialize (msg)
The error will be
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/E7/wKiom1XAqcHzy0TMAATtPObxBog225.jpg "title=" Error message. png "alt=" wkiom1xaqchzy0tmaattpobxbog225.jpg "/> Problem specific reasons not found, the phenomenon is also relatively special, For example, when I enter 2000000.00, the message turns into a scientific notation, and I enter 2000000.12 or 2000000.1 so that it does not turn into a scientific notation, which is why the problem has not been discovered before.
Fix this bug method: Because many places such use, so the message form inconvenience change, had to change a jar.
2, the use of Json-lib-2.4-jdk15.jar, and encountered a new problem, the loss of precision, this is a better solution.
The jar source code out, found that the number of the type of numbers, instead of bigdecimal, it changed this place to Createbigdecimal
Scientific notation and accuracy questions about JSON deserialization strings as Java objects