Answers for "how to get string from json object in c#"

2

c# get value from json object

using System;
using Newtonsoft.Json.Linq;

namespace testClient
{
    class Program
    {
        static void Main()
        {
            var myJsonString = "{report: {Id: \"aaakkj98898983\"}}";
            var jo = JObject.Parse(myJsonString);
            var id = jo["report"]["Id"].ToString();
            Console.WriteLine(id);
            Console.Read();
        }
    }
}
Posted by: Guest on June-11-2021
-2

string json to object c#

var resultCon = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonStr);

//or
string json = "{\"ID\": 1, \"Name\": \"Abdullah\"}";
User user = JsonConvert.DeserializeObject<User>(json);
/*
public class User
{
    public int ID { get; set; }
    public string Name { get; set; }
}
*/
Posted by: Guest on January-20-2021

Code answers related to "how to get string from json object in c#"

Code answers related to "Javascript"

Browse Popular Code Answers by Language