Click here to Skip to main content
15,037,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new in json.
In my project i need to deserialize json data come from amazon service url .

this is my json  format <a href="
https://s3.amazonaws.com/afb-ses/bounce.json">json list</a>

<pre lang="HTML">{"complaint@simulator.amazonses.com":{"time":"2018-01-02T20:45:46.650Z","type":"Complaint","bounceType":"null","bounceSubType":"null"},
"struax@afb.net":{"time":"2018-01-02T20:53:03.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"},
"bounce-test@service.socketlabs.com":{"time":"2018-01-02T21:06:40.097Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"},
"bounce@simulator.amazonses.com":{"time":"2018-01-02T21:08:02.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"General"},
"jstrechay@afb.net":{"time":"2018-01-05T06:31:39.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"General"},
"leematt45@hotmail.com":{"time":"2018-01-05T06:49:13.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"},
"afbweb@afb.net":{"time":"2018-01-07T12:50:38.000Z","type":"Bounce","bounceType":"Transient","bounceSubType":"General"},
"rushjenacath@gmail.com":{"time":"2018-01-05T06:32:42.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"},
"Kerryhoskins0925@gmaiil.com":{"time":"2018-01-02T09:18:20.000Z","type":"Bounce","bounceType":"Transient","bounceSubType":"General"}}


i need to ave this record in db and my db table column's are Email ,type, time,bounceType, bounceSubType.
i am not understand how to do this and this is the link where i get the json json link for details
thanks in advance

What I have tried:

this is i tried

 <pre lang="c#"> using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString("https://s3.amazonaws.com/afb-ses/bounce.json");
                string jsonData = JsonConvert.SerializeObject(json);
                var _userin = JsonConvert.DeserializeObject(jsonData);

               
            }


in this code json is Deserialized with tree structure but how to save in DB
Posted
Updated 9-Jan-18 4:18am
v3
Comments
Dotnet_Dotnet 9-Jan-18 9:51am
   
for three structure sir you should have nested entity class a properties of a calass contain another class object

1 solution

try

dynamic _userin = JsonConvert.DeserializeObject(json);
       foreach (var item in _userin)
       {
           string name = item.Name;
           string time = item.Value.time;
           string type = item.Value.type;
           string bounceType = item.Value.bounceType;
           string bounceSubType = item.Value.bounceSubType;
       }


this is one of the method to get the values, have a look on this article [^] by Graeme, you wll find lot on C# JSON
   
Comments
Graeme_Grant 9-Jan-18 10:42am
   
5'd
Karthik_Mahalingam 9-Jan-18 11:30am
   
Thank you Graeme

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900