How to Parse JSON in C#
C# has built-in JSON support with System.Text.Json
since .NET Core 3.0. Unlike Java which requires external libraries, C# includes JSON functionality out of the box, though not as seamlessly as JavaScript.
Using System.Text.Json (.NET Core 3.0+):
using System;
using System.Text.Json;
string jsonString = "{\"name\":\"Claus Witt\",\"ideas\":[\"idea one\",\"idea two\"]}";
JsonDocument doc = JsonDocument.Parse(jsonString);
Console.WriteLine(doc.RootElement.GetProperty("name").GetString());
JsonElement ideas = doc.RootElement.GetProperty("ideas");
Console.WriteLine(ideas[0].GetString());
Using Newtonsoft.Json (older .NET versions):
using Newtonsoft.Json.Linq;
JObject obj = JObject.Parse(jsonString);
Console.WriteLine(obj["name"].ToString());