JSON Toolkit for LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in JSON Toolkit v2012-12-20: Incorrect decimal place

Hi there,

first of all - thanks for this great and easy to use toolkit.

While starting to implement it I've stumbled over this problem.

On german OS the decimal place is a comma not a point. So the resulting JSON object looks like this:

{"cmd":4,000000,"key":[],"value":[]}

but should look like this to be a valid JSON object:

{"cmd":4.000000,"key":[],"value":[]}

I've attached the 2 modified files. Now converting to and from JSON works.

UPDATE:

I've attached an updated version of the JSON Tree Base Type to String.vi

this update correctly converts double, single and integer values.

Now there are no 0s at the end of a (decimal) number. Integer values are now integer values without a dot or 0s

situation before:

{"i32":3.000000,"sgl":2.500000}

now:

{"i32":3,"sgl":2.5}

The converted string is now smaller in size and better readable 🙂

Download All
0 Kudos
Message 1 of 8
(14,674 Views)

see the first post for the update - if one already downloaded the files, redownload the JSON... vi

0 Kudos
Message 2 of 8
(11,194 Views)

Hi BastiFantasti!

I like the idea of changing the format string to %#g as that is a pretty quick change and looks good. Also thanks for the localization catch! I'll add both changes to the next release.


Milan
0 Kudos
Message 3 of 8
(11,194 Views)

Hi MilanR

ok and thanks for the reply. The string needs to be %.;%#g otherwise using a dot as decimal place isn't forced.

Best regards,

Basti

0 Kudos
Message 4 of 8
(11,195 Views)

Will do! Thanks :]


Milan
0 Kudos
Message 5 of 8
(11,195 Views)

Hi, thanks for the really nice JSON library.

With respect to the formatting of numeric values, a short question arised within my project.

One result of the automatic formating (%.;%#g) is, that larger decimal numbers (UNIX timestamps in my project - 1374666515 as an example) are formatted in scientific notation (1.374667E+9), losing information.

Is there a way to encode such decimals as numeric values, since encoding within a string value seems a bit strange for a is-always-a-number value?

Sorry, if this functionality is already present and I simply missed it.

Thanks!

0 Kudos
Message 6 of 8
(11,195 Views)

Hi Locutio,

you're right - large numbers are converted in scientific notation.

This issue can be fixed with using: %.;%#f as format string

can you please try if this fixes your issue?

Regards,

Bastian

0 Kudos
Message 7 of 8
(11,195 Views)

Hi Bastian,

thanks for your response. The format string %.;%#f  does indeed produce the correct output for me.

0 Kudos
Message 8 of 8
(11,195 Views)