1

i am a newbie to coding , I have a nested json coming from a external source the json format is looks something like this ..

{
 "data":"data",
 "data":
       {
         "data":"data",
           //----------------e.t.c the internal objects could be in n number
       }
}

so how do i deserialize the json object and use the data as a list in order to do my other operations like sql and posting the data??

ZaoTaoBao
  • 2,567
  • 2
  • 20
  • 28
Sai Chaitanya
  • 195
  • 1
  • 1
  • 13
  • Check out [this](http://stackoverflow.com/questions/7895105/deserialize-json-with-c-sharp) and [this](http://stackoverflow.com/questions/7699972/how-to-decode-a-json-string-using-c/7701070#7701070) SO question –  Apr 18 '16 at 07:39

1 Answers1

2

You need to create a class that is appropriate with the Json, like that:

public someClass
{
    public string data1 { get; set; }
    public DataClass dataArr { get; set; }
}

public DataClass
{
    public string insideData { get; set; }
}

after you do this you need the following code:

var jsonDto = JsonConvert.DeserializeObject<someClass>(yourJson);
israel altar
  • 1,768
  • 1
  • 16
  • 24