I am receiving a response from API in below string format:
"{"nbf":2024-04-17T16:28:14.509+0800, "iat":2024-04-17T16:28:14.509+0800, "iss":"https://google.com" }"
When I am trying to use JObject.Parse() method then I am getting below error:
"Unexpected character encountered while parsing number: T. Path ‘nbf’"
2
Answers
The property
nbf
appears to have the value that is a ISO date time; but JSON has no support for date time values.Such a date time needs to be serialised as a string (ie. in double quotes).
Likely the invalid character is the first
-
because the prior characters in the value would otherwise be a number,.For the full details of the JSON format see https://www.rfc-editor.org/rfc/rfc8259 section 3.
your best approach is to insert " before serializing.
P.S. I wrote fast, code can be refactored for better…