Home  • Programming • ASP.NET Core

Parse json in C# ASP.net core

Method 1 select-name-cmbcountry using Newtonsoft.Json;
dynamic stuff = JsonConvert.DeserializeObject("{ 'Name': 'Jon Smith', 'Address': { 'City': 'New York', 'State': 'NY' }, 'Age': 42 }");

string name = stuff.Name;
string address = stuff.Address.City;
Method 2 using Newtonsoft.Json.Linq;
dynamic stuff = JObject.Parse("{ 'Name': 'Jon Smith', 'Address': { 'City': 'New York', 'State': 'NY' }, 'Age': 42 }");

string name = stuff.Name;
string address = stuff.Address.City;

Comments 0


Copyright © 2025. Powered by Intellect Software Ltd