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??

1
  • Check out this and this SO question Commented Apr 18, 2016 at 7:39

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

3 Comments

so for this solution the inside data can be { "x" : "x" , "y":"y" ....... ,} am i right???
@SaiChaitanya i didn't understand...what do you mean please?
I mean to say the internal data ,i.e. the nested json can be {"data1:data1,........,n different data} correct ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.