You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an issue with serialization and parsing of JTD schemas which contain a 'timestamp' type.
When I serialize an object which contains a property of type 'Date' as a 'timestamp', the resulting JSON string contains the date in
RFC3339 format, but not enclosed in quote signs ('"'). This leads to the fact that the parser is not able to parse the JSON string.
What version of Ajv are you using? Does the issue happen if you use the latest version?
I am using the latest version ajv@8.6.1
Ajv options object
I am using the default options:
constajv=newAjv();
But I have also tried the following JTD specific options:
constajvConfig: JTDOptions={timestamp: 'date'// also tried 'string',parseDate: true,// also tried false};constajv=newAjv(ajvConfig);
JSON Schema
A minimal example is given as follows:
I am experiencing an issue with serialization and parsing of JTD schemas which contain a 'timestamp' type.
When I serialize an object which contains a property of type 'Date' as a 'timestamp', the resulting JSON string contains the date in
RFC3339 format, but not enclosed in quote signs ('"'). This leads to the fact that the parser is not able to parse the JSON string.
What version of Ajv are you using? Does the issue happen if you use the latest version?
I am using the latest version ajv@8.6.1
Ajv options object
I am using the default options:
But I have also tried the following JTD specific options:
JSON Schema
A minimal example is given as follows:
Sample data
I am expecting the serializer to produce a JSON string as follows (notice the date is enclosed in quote signs):
Your code
The code can be found at Runkit.
Validation result, data AFTER validation, error messages
The JSON string produced by the serializer looks as follows:
'{"foo":2021-07-15T15:21:00.322Z}'
The parser shows the following message:
"unexpected token 2" (at position 7).
Note that position 7 is the first digit of the date.
What results did you expect?
I expect the serializer to produce a JSON string in which the date is quoted:
'{"foo":"2021-07-15T15:21:00.322Z"}'
If I manually quote the date, the parser does not complain and no error occurs.
Are you going to resolve the issue?
No
The text was updated successfully, but these errors were encountered: