JsonElement Parameter has valuekind undefined even after passing data?

620 views Asked by At

I created a method that takes in a JSONElement parameter. The problem is that whenever I execute the method and pass it a json object, the parameter is always of value undefined.

Why is this happening?

The following is the method that I am trying to work with:

public string GetJsonElement(JsonElement data)
        {
          return "Done";
        }

Whenever I put breakpoints in my code to check the data parameter's value, this keeps showing up:

data ValueKind = Undefined : "" System.Text.Json.JsonElement

The Json I am passing:

{
"User":"User1",
"FullName":"Jane Doe"
}

Could someone shed some light on what is happening and how I can maybe get rid of the problem please?

1

There are 1 answers

1
kriti gupta On

I was able to resolve by removing newtonsoft as my serializer for mvc from startup