I am using web connection 7.20 to consume RestAPI. The api sends json response where one field called upset_at always has a value in this format: 2021-05-16T04:46:11.522669Z
My question: Is there any way upon deserialization I could retain the value as is. I know it cannot be converted to VFP datetime as is, but how if I could get it as a string?
Not sure what you're asking. wwJsonSerializer
will deserialize JSON dates into FoxPro. There's no support for returning the raw value as a string, since the serializer will always deserialize the date.
+++ Rick ---
Some property on the serializer where one could provide a list of json attributes whose values should not be cast rather left as string.
Thanks
This is not supported.
+++ Rick ---
Serialization customization for specific types is not supported.
But if you are concerned about the date that you are referencing that is automatically deserialized into a FoxPro date. That date you show is a standard JSON date and the serializer understands that.
+++ Rick ---
Hi Zul,
If the name of the property is consistent, you could use string manipulation to wrap the JSON datetime with quotes before you deserialize the JSON. It should then treat the datetime as a string.
I had to do something like this with JSON responses that have "id" fields that are 64-bit integers.
Eventually, they may become too large for FoxPro to handle as integers so I wrap them with quotes before deserializing and handle them as strings.
Carl
Thanks Carl. I will try your suggestion.
I am not trying to convert that datetime with timestamp into VFP date time. I simply want to retain that exact value as is and pass it to Postgres.
I am using cursor adapter and mapping the upsert_at column as C(30) to Postgres date time with timestamp column and this retains the exact value as is in the Json response.
Thanks Rick.
But why? Does the Postgres driver not support real date values? You should be able to upsert a FoxPro date into a Postgres date and vice versa.
If you don't want a date, don't use a date...
+++ Rick ---