L
L
Leonius_Bad2018-06-11 08:18:20
Java
Leonius_Bad, 2018-06-11 08:18:20

Java. How to parse and translate JSON into XML without scientific (exponential) notation of numbers?

There is the following task/problem. From the server I receive the answer in the form of JSON'a. Using Java, you need to translate this JSON into a string containing valid XML.
Initially used org.Json . It can both parse json from a string and translate parsed JSON into XML. Everything would be fine, but this library converts large / long numbers into an exponential (scientific) form, which I do NOT need in the final XML string. How to display numbers in a normal form using org.json, I did not understand. Next I tried Gson . It parses JSON without any exponents (it even has a corresponding setting), but I didn’t figure out how to convert gson to XML. =_=
Surely someone has already solved a similar problem? Please tell me the recipe for converting JSON to XML in Java, keeping the numbers in their normal form.
And yes, Json comes from the server without exp.forms of the record.
PS It would be ideal if the specified answer-solution normalized those numbers that come from the server in scientific form (well, what if they come?) , But this is already additional and optional :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vko, 2018-12-16
@vko

Underscore-java can convert json to xml. U.jsonToXml(string) method. For large numbers, BigDecimal is used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question