LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Assistance with JSONtext - From JSON Text

Solved!
Go to solution

So, I am dabbling in the world of JSON using the JSONtext VIs from JDP Science. In my very simple example, I have a first name, last name, and a date of birth which I think I have formatted correctly. When I run my VI, I can't seem to extract the data via my simple JSON string and end up with an error:

 

Eric1977_0-1721922512830.png

 

Since this is my first time working with JSON, I don't know exactly what the problem is. I'd appreciate the assistance of what to look for.

 

The VI that is attached should be down converted to v18.

0 Kudos
Message 1 of 8
(636 Views)

You need quotes around the date.  Even then, I am getting a different error (Not a supported timestamp format).  I'll have to dig in order to get to the bottom of that one.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(622 Views)
Solution
Accepted by topic author Eric1977

Date/Time stamp must be a string in ISO8601 format

santo_13_0-1721926137325.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 3 of 8
(611 Views)

Hmmm, I wonder why the date that gets returned from the date time constant returns 8:00:00 PM? I am in the Eastern Time Zone.

 

Eric1977_0-1721928399217.png

 

0 Kudos
Message 4 of 8
(600 Views)

@Eric1977 wrote:

Hmmm, I wonder why the date that gets returned from the date time constant returns 8:00:00 PM? I am in the Eastern Time Zone.


Eastern Daylight Time (EDT) = UTC-4:00 => 12-4 = 8


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 8
(598 Views)

Santo - how did you know that the JSON dates need to be in the ISO format you linked? That link you posted appears to go to Wikipedia. Is there a website of whitepaper that speaks to that?

 

Perhaps it is in there and I just skipped over it.

 

Eric

0 Kudos
Message 6 of 8
(520 Views)

The way I figured it out was a mix of experiment and experience but not through documentation.

 

From using JSON extensively in Python, typically, the ISO format is used. I tried the "Anything to JSON" VI with Timestamp data and the JSON text obtained showed the familiar ISO format with T and Z characters.

 

https://docs.jsonata.org/date-time

santo_13_0-1721999665906.png

 

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 7 of 8
(510 Views)

If you look inside the 'To JSON text' and 'From JSON text' functions, you will find calls to a dependent JDP Timestamp Library that describes the string formatting as RFC 3339.

 

JSON has no native timestamp data type.


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 8 of 8
(502 Views)