LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extended Ascii on JSON

Solved!
Go to solution

Hi,

 

I have a JSON setting file witch is loaded from my .VI

My JSON is like this:

Nalofox_1-1676158660310.png

I need to write the charactère 0x00 which is \u0000 but when I do that labview can't interpret it:

It replaces all the data by "?".

Nalofox_2-1676158750296.png

Here is my the labview structure I use:

Nalofox_3-1676158874448.png

 

Do you have a fix?

Thanks for taking a look at my situation.

 

0 Kudos
Message 1 of 6
(1,359 Views)
Solution
Accepted by Nalofox

The standard JSON functions that come with LabVIEW have a known bug of truncating strings at the first zero, even if that zero is properly represented as \u0000.  You will need to use a different JSON library, such as JSONtext (which I wrote).

 

BTW, you shouldn't need to do all that utf8 conversion; the JSON functions should handle that.

0 Kudos
Message 2 of 6
(1,317 Views)

Thanks for your response.

 

So I have used the lib you tell me JSONtext and it works well,

Here's is my labview (there may be a better way to do this).

Nalofox_1-1676222145217.png

 

Have a good day

0 Kudos
Message 3 of 6
(1,283 Views)

Hello, I'm beeing using the JSONtext library for a while and I'm still having issue with the "From Json text.vi". 

 

The VI does not convert properly Extend ASCII format. Those caracter are convert to "?"

 

Is there a way to force the VI to convert correctly? 

jrslaurentopsenscom_0-1727454248082.png

 

0 Kudos
Message 4 of 6
(267 Views)

I have used JSONtext in the past for many JSON things I run into, but I have found the same thing as you when trying to import text using upper ASCII in it.

 

To be fair to the JSONtext library I have been using an old version (1.4.4.89) so it may be better now.  There are some things in recent patch notes I see about Unicode which might also imply support for upper ASCII.

 

On an application where I encountered upper ASCII, I used the "i3 JSON" toolkit instead:

https://www.vipm.io/package/i3_json/

 

It's not as easy to use and seems to be a bit slower, but it also didn't have a problem with those extended characters.

 

So I would try first seeing if you have an updated version of JSON text and if that doesn't work, try the i3 library.

0 Kudos
Message 5 of 6
(259 Views)

Your problem lies with whatever produced your psuedo-"JSON" string, as JSON is always UTF-8 encoded.  Interpreted as UTF-8, your string has invalid characters, that show up as question marks when JSONtext tries the convert the "UTF-8" to extended ASCII.

If you can't fix the bug in the code generating the input string, try converting it to UTF-8, using the (off-pallet) conversion function:

2024-09-28 14_34_19-Untitled 2 Block Diagram _.png

 

0 Kudos
Message 6 of 6
(231 Views)