09-24-2019 04:36 AM
Hello,
I have a LV application that makes intensive use of JSON to transmit real time data to http clients. I'm trying to reduce the data bandwith consumption and improve the user experience on poor networks limiting the number of decimals of the JSON arrays of numbers. Because the clients only use 4 significant figures, and the rest of decimals are useless traffic.
I have developed a VI that does the job. The problem is that if I make the output of this VI to be a string, then when I parse to JSON I will have an array of strings instead of numbers. And if I change the output to DBL, then things like this happens:
DBL: 1234,1; JSON String: [1234.0999999999999091].
So... I don't see a clear way to do this. And it would be highly preferable to not have to change the clients' code...
I look forward your ideas. Best regards,
EMCCi
Solved! Go to Solution.
09-24-2019 05:12 AM
The in-built LabVIEW functions are very verbose, but you can use JSONtext (on Tools Network) instead, which is designed to represent decimal numbers exactly. This will flatten 1234,1 to 1234.1.
09-24-2019 05:57 AM
Thanks for your response. Didn't know about these tools.
Anyway, while waiting for an answer I was working on my solution. It only work for arrays, but it could be easily modified to work also with clusters. I upload it just in case it could be useful for someone.
Thanks and regards,
EMCCi