【发布时间】:2017-05-24 09:58:24
【问题描述】:
如果我的英语有时不确定,我是法国人,很抱歉... 我在工作场所工作了 6 周(我在这个领域很新……),他们希望我将实际的数据库(json)传输到 SQL 中的真实服务器,并且全部使用 C#。我需要用 C# 读取 JSON 文件,将其转换为 C# 对象。
有一个json DB的例子:
{
"updated": "2015-05-20T13:16:00.000Z",
"title": "Chaîne Activité",
"description": "Vidéos des activités diverses du Webcenter",
"items": [
{
"id": "77B6573B-47E4-4D60-A6FC-99E81EF05404",
"uploaded": "2014-07-02T12:56:00.000Z",
"uploader": "Inconnu",
"category": "activité//Pléniére",
"title": "Teaser de la plénière 2014",
"description": "Marc Emmanuel de 'Tous Ensemble' et Axa Atout Coeur vous invite à la 3éme plénière.",
"thumbnail": "/Content/img/video/activite/teaser-pleniere-2014-.png",
"duration": 66,
"path": "Plénière-2014-teaser.mp4"
}`
还有我的课:
public class Item
{
public string Id { get; set; }
public string UploadDate { get; set; }
public string Uploader { get; set; }
public string Category { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Thumbnail { get; set; }
public int Duration { get; set; }
public string Path { get; set; }
}
请记住,我不是专业人士,感谢您的帮助! :)
【问题讨论】:
-
那你累了什么?
-
您想使用 NewtonSoft Json nuget 包将 JSON 反序列化为您的对象。然后使用他们使用的任何 DB 技术,无论是 EF 还是 ADO 将其导入 db。
-
我现在拥有 Newtonsoft,我会和我的“老板”一起看看 ADO
标签: c# json serialization