07-25-2024 10:57 AM
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:
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.
Solved! Go to Solution.
07-25-2024 11:32 AM
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.
07-25-2024 11:50 AM
Date/Time stamp must be a string in ISO8601 format
07-25-2024 12:27 PM
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.
07-25-2024 12:30 PM
@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
07-26-2024 07:50 AM
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
07-26-2024 08:14 AM
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
07-26-2024 08:26 AM
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.