So I am writing a wrapper for JsonNode to easier extract json properties when there is no data-contract and I need to support a plethora of different values. But I am having some issues when it comes to reading an empty value. So either I am doing something wrong, or JsonNode is the wrong class to work with here.
My test-json is the following:
{
"id": 3,
"name": null
}
And I am doing different kind of queries against the JsonNode.
_node.HasProperty("id") will return true, but
_node.HasProperty("name") will return false.
So is there a way to achieve this?
Please advice.
JsonObjectand useContainsKey("name")_node.AsObject()to get an instance of the JsonObject, and then useContainsKey()just like you said. Please add a reply here and Ill mark it as the correct answer.HasPropertyimplementation, as this was suggested here github.com/dotnet/runtime/issues/47649#issuecomment-812123225 but never implemented.