LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

json with type double number

Solved!
Go to solution

Alternatively I guess you could use format the number as a string with x amount of places of precision.  It seems the goal of the display is to make it user friendly.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 11 of 17
(169 Views)

Thanks.  jsontext is what I am using.

 

The string conversion VIs do provide an optional input for a class conversion routine, but it only gets called for classes, and an array of doubles is not a class, so I guess what I could do is create a class just for the purpose of converting double values to strings, and convert my array of doubles to an array of this class, than wire in another class that knows how to convert the values to strings using reasonable formatting.  That just seems like a lot of trouble to have to go to.... but I guess it would work.

0 Kudos
Message 12 of 17
(139 Views)

The problem with pre-converting the doubles to properly-formatted strings, is that then the JSON-to-string conversion puts things like "value": "3.14" rather than "value": 3.14.

 

In other words, the values become strings in the JSON, rather than numbers.  I need the string conversion to format the values without converting them to strings in the JSON.

 

As I said in another response, I think what I have to do is:

 

1. Create a special-purpose class that contains a double value, and knows how to properly format the value in JSON, then

2. Create another special-purpose class that implements JSONtext's serializer interface, then

3. When calling JSON-to-string VIs, first convert my arrays of doubles to arrays of the first class, and wire in the second class as the class-to-string serializer (an option input, but it only works for classes).

 

I think that would work, but it just seems like a lot of trouble to have to go to.

0 Kudos
Message 13 of 17
(137 Views)

@TimBlaisdell wrote:

Thanks.  jsontext is what I am using.


Can you show how you are using it?  I ask as JSONtext formats 12.1 as 12.1 and 355.47 as 355.47, so you should not be having your problem if you are using JSONtext.

0 Kudos
Message 14 of 17
(121 Views)

If you're concerned about the web service rounding or truncating data, then what happens when you send 9999.12 just as you were going to, or any double-precision number, to the web service?  How does that data come back to you? Does it?

 

It sound like that is the question you want answered based on what I have read.

0 Kudos
Message 15 of 17
(99 Views)

Replying to :

 

Wow.  You're right, thank you.

 

I was comparing the values (which are wavelengths from a hyperspectral camera) to the values in a table in the camera documentation.

 

It turns out, the actual values being returned by the camera DO have all the extra digits for whatever reason.  Probably they are being rounded away in the published table (for the same reason that I want to round them).  

 

So, the extra digits probably ARE really more accurate and not just an artifact of digital representation.  However, I'd still like to format them out in the interest of storage and readability.  In my line of work, values with many digits of precision are frowned upon because they imply a claim of accuracy that we cannot back up.

0 Kudos
Message 16 of 17
(88 Views)

@TimBlaisdell wrote:

It turns out, the actual values being returned by the camera DO have all the extra digits for whatever reason.  Probably they are being rounded away in the published table (for the same reason that I want to round them).  


The reason being that 1.1 can't be represented correctly in a 1+0/2+0/4+0/8+1/16+1/32+1/64... format.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 17 of 17
(72 Views)