0

From an API call I am getting some JSON data, I dont want to declare a class, while in NewtonSoft we can get those data as given below without creating a class,

JObject o1 = JObject.Parse(File.ReadAllText(@"example.json"));
Console.WriteLine(o1["customername"]);

Is there any similar way to get json data without creating a class in System.Text.Json

Edit:

I was able to proceed by the solutions provided here How do you read a simple value out of some json using System.Text.Json?

Akishere
  • 37
  • 5

1 Answers1

0

You could try using JSON document model and parse subsections you are interested in. See this link https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter?pivots=dotnet-6-0#deserialize-subsections-of-a-json-payload

aeje
  • 239
  • 1
  • 9