This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
I have a problem with fields of ValueType DATETIME.
When I look into the body log file of the response it contains Datetime elements like this:
"pickUpDateTime":"2022-09-14T12:00:00.000+00:00"
JSONReader identifies this as ValueType = DATETIME.
When I try to read this field with
#JsonReader.TokenText.AsNativeString I get the result "14.9.2022 12:0:0:0"
#JSONReader_TokenText := #JsonReader.TokenText.AsDateTime.AsString the programme crashes
#JSONReader_TokenText := #JsonReader.TokenAsDateTime.AsString Or #JSONReader_TokenText := #JsonReader.TokenAsDateTime( ISO ).AsString return "00:00:00".
I want to work exactly with the field value "2022-09-14T12:00:00.000+00:00" that I found in the log file.
How can I read the field just the way it was delivered without any conversion?
Because of large amount of resonse data (much more than 65535 characters) I have to work with Define_Com Class(#PRIM_JSON.Reader) Name(#JsonReader) Textreader(#TextReader)
instead of Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
I receive the response as a BLOB and transfer this to work with #PRIM_JSON.Reader:
* Create empty temporary file
#TempFile.CreateTemporaryFile
* Save HTTP response to temporary file
#HTTP_Request.Response.AsFile Autodelete(True) Path(#TempFile)
* Do the reading using JsonReader
#FileStream.Path := #TempFile
And then read JSONReader in a DO WHILE loop.
How can I retrieve the correct DATETIME value using JSONReader here. When I use AsNativeString here (#JsonReader.TokenText.AsNativeString) I get the result "14.9.2022 12:0:0:0" instead of "2022-09-14T12:00:00.000+00:00".