-3

How do I parse below JSon string to get the value of RESULT & ERROR?

{
    "RESPONSE": [
        {
            "DT": "20210317",
            "I_NO": "1031021",
            "C_NO": "1021",
            "RESULT": "E",
            "DCODE": "2-B1",
            "ERROR": "[AMT] is mandatory."
        }
    ]
}
user3607582
  • 61
  • 11
  • https://www.newtonsoft.com/json/help/html/SerializingJSON.htm – Chetan Mar 17 '21 at 06:03
  • https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to?pivots=dotnet-5-0 – Chetan Mar 17 '21 at 06:03
  • Does this answer your question? [How can I deserialize JSON to a simple Dictionary in ASP.NET?](https://stackoverflow.com/questions/1207731/how-can-i-deserialize-json-to-a-simple-dictionarystring-string-in-asp-net) – Udhay Titus Mar 17 '21 at 06:04

1 Answers1

2

Create your c# class for deserialization.

public class RESPONSE
{
    public string DT { get; set; }
    public string I_NO { get; set; }
    public string C_NO { get; set; }
    public string RESULT { get; set; }
    public string DCODE { get; set; }
    public string ERROR { get; set; }
}

public class Root
{
    public List<RESPONSE> RESPONSE { get; set; }
}

Then Deserialize with Newtonsoft

var response = JsonConvert.DeserializeObject<Root>(jsonString);
Eren Peksen
  • 175
  • 2
  • 10