如何反序列化这个json代码并将其存储在sql中

时间:2017-02-18 14:39:02

标签: c# json

 {
     "payload": {
         "coordinators": [
             {
                 "coordinatorID": "1",
                 "remarks": "a",
                 "briefObservation": "a",
                 "justifyingRecommendation": "a",
                 "sectors": [
                     {
                         "sectorNumber": "8",
                         "projectDescription": "a",
                         "knowledgeMarks": "a",
                         "siteMarks": "a",
                         "impactAccessmentMarks": "a",
                         "empAddressingMarks": "a",
                         "totalMarks": "a",
                         "recommendation": "a",
                         "category": "a"
                     },
                     {
                         "sectorNumber": "10",
                         "projectDescription": "a",
                         "knowledgeMarks": "a",
                         "siteMarks": "a",
                         "impactAccessmentMarks": "a",
                         "empAddressingMarks": "a",
                         "totalMarks": "a",
                         "recommendation": "a",
                         "category": "a"
                     }
                 ]
             }
         ]
     },
     "status": 0,
     "message": "Success/Fail Reason"
 }

2 个答案:

答案 0 :(得分:1)

Json.NET是你的朋友。您可以直接在文档中找到示例。

http://www.newtonsoft.com/json/help/html/SerializingJSON.htm

“将其存储在SQL中”有点通用。在不知道有问题的数据库或更多的实现目标而不是标记“C#”我只能猜测。这里是Youtube视频教程的另一个链接 - 连接到MySQL数据库并使用C#插入数据。

https://www.youtube.com/watch?v=U3bVc7E6UHA

答案 1 :(得分:1)

你有一篇文章可能有用here用c#反序列化json:

要将对象保存到数据库,您可以查看此documentation