HELLO! I have two problems with the JSON function....
# klaxon
s
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
But it’s UTF encoding and it’s completely fine (this many json libraries support both encoded and raw formats for encode/decode)
s
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
Yes, it's standard utf escaping, so it will be decoded, same way as corresponding JVM string which also supports utf escaping
s
Oh, well. Thank you!