LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unflatten from JSON does not like tab character (\t, 0x09)

Solved!
Go to solution

Getting error -375003 when running the attached VI. The string in the control has a tab character (\t) after the letters "AFE". If I remove the tab or replace it with a space character (\s), the VI runs fine. From my understanding, there should be no issue with the tab character.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 1 of 7
(6,104 Views)

JSON, by its official spec, does not allow actual tabs in it.

 

Just add in a find-and-replace node that replaces all actual tabs with "\t", or find the source of the JSON and change it to comply with the official spec.

0 Kudos
Message 2 of 7
(6,071 Views)

Here's the entire JSON spec, where it shows that tabs need to be escaped (in the definition of "string").

0 Kudos
Message 3 of 7
(6,018 Views)

Is the spec you are referring to different from the one wiebe@CARYA is referring to? It says horizontal tab characters are allowed, as long as they are escaped.

 

And in my case, the string I am trying to decode is using the escaped version of the tab character. I even tried using LabVIEW's tab constant and I get the same error.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 4 of 7
(6,005 Views)
Solution
Accepted by topic author B.Settles

@B.Settles wrote:

Is the spec you are referring to different from the one wiebe@CARYA is referring to? It says horizontal tab characters are allowed, as long as they are escaped.


It's the same spec. There's only one spec.

 


@B.Settles wrote:

And in my case, the string I am trying to decode is using the escaped version of the tab character. I even tried using LabVIEW's tab constant and I get the same error.


LabVIEW's tab constant is not an escaped tab character, it's a tab character. Your string contains an unescaped tab character. Both are expected to give an error.

 

If you set your display to "\" mode, you see "\t". That is a tab, not an escaped tab. It should be "\t" in normal mode, or "\\t" in "\" mode.

 

How do you build the string? If you'd use the Flatten To JSON, you'd be sure it's valid JSON.

Message 5 of 7
(6,000 Views)

Thanks for the clarification. I thought because is was a \t in "codes display" it was escaped. The string is coming from device, so they'll have to update their firmware.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 6 of 7
(5,977 Views)

@B.Settles wrote:

Thanks for the clarification. I thought because is was a \t in "codes display" it was escaped. The string is coming from device, so they'll have to update their firmware.


Or alternatively, or as a temporary workaround, do a Search And Replace. Search for tabs ("\t"), replace with \t ("\\t").

 

It would of course be better if they changed there output to valid JSON. If they claim to send valid JSON, they have a bug.

0 Kudos
Message 7 of 7
(5,954 Views)