I have a function that receive a JObject, and in one case the Json that I receive are this:
{}
and I was trying to manage with this:
public void GetSomeJson(JObject request)
{
if (request==JObject.Parse("{}"))
throw new ArgumentNullException("The request are null");
//more stuff
}
In this way doesn't work, and jump the condition, any idea to recognize the Json received is null or blank?
JObject
is a container for properties and implements IDictionary<string, JToken>
to access them, so this would test if an object has zero properties:
if (request.Count == 0) { /* The object is empty */ }