https://kotlinlang.org logo
#klaxon
Title
# klaxon
s

Spel98

05/29/2019, 11:24 AM
HELLO! I have two problems with the JSON function. I have a Molecule object that contains some values ​​... the first problem is with the weight field, of type Float with 3 decimal digits and when I go to create the string Json brings me back a float with a lot the numbers after the comma, in practice the number stops being rounded to 3 digits after the comma. The second problem is with strings containing codes separated by gods + or -. For example the string "301 - 372 - 314 - 410" in json becomes "301\u200b\u2010\u200b372\u2003\u200b314\u200b\u2010\u200b314" and the numbers to the subscript of the formulas as "Hg-⌬-NO₃" become "Hg-⌬-NO\u2083". As if the json didn't use the same charset used for strings in the fields of the object. Does anyone know if there are any parameters to change in the json function? In particular I am taking a list of values ​​from a file separated by some \ to transform them into json ... each line of the file contains the data of a molecule. In practice I am converting an old data saving format to json. But there are problems during the conversion. Note that in the second output the problem with the character - does not occur
g

gildor

05/29/2019, 11:36 AM
But it’s UTF encoding and it’s completely fine (this many json libraries support both encoded and raw formats for encode/decode)
s

Spel98

05/29/2019, 11:44 AM
So when I parse the json file to read the data there will be no problems because the escape characters will be converted directly into the corresponding character?
g

gildor

05/29/2019, 11:57 AM
Yes, it's standard utf escaping, so it will be decoded, same way as corresponding JVM string which also supports utf escaping
s

Spel98

05/29/2019, 11:58 AM
Oh, well. Thank you!
16 Views