FastJsonParser
FastJsonParser copied to clipboard
Parsing a blank "" as null
I am parsing a string to a POCO object. One of the fields is a nullable long. But in the json it has the value surrounded by strings like so and looks like an empty string.
{ "reqBegin": "1431462651083", (long?) "reqEnd": "" (long?) <-- should deserialize to null }
The parser blows up on reqEnd if it is an empty string, instead of setting the object's field value to a null.
I tried to fix this and submit a pull request but I am struggling to figure out how the ParseInt64 and Obj() methods work.
Can someone fix this for me?
In the current design & implementation, the syntax of allowed constants of a given nullable type used at the target POCO is either (a) that of its underlying non-nullable (struct) type, or (b) the JSON null value. Still, I'll try to have a closer look at the use case you're alluding to/thinking of, asap.
'HTH,
Thanks @ysharplanguage, I understand the document doesn't follow protocol. But when does anything?
@sporty81 Another issue nobody opened is the need for more organized and manageable unit tests, instead of the current ad-hoc ones. I will address this as well in the next few commits.