将数据从file.json转换为sqlserver中的datatable,反之亦然 [英] Convert data from file.json to datatable in sqlserver verse versa
问题描述
我需要创建Web服务web api,我需要创建CRUD和菜单但我有数据作为json文件,我需要将数据从file.json转换为sql server中的datatable并转换来自sql server的数据自动提交.json。因为当数据变成tabe中的数据时很容易在MVC中创建CRUD web api C#
有任何人有任何想法,请帮助
我尝试过:
没什么。
< blockquote>反序列化你的json集合:
反序列化收集 [ ^ ]
之后,编写一个方法将您的反序列化对象转换为数据表,Bob是您的叔叔。
BTW,如果你使用netwtonsoft json.net库(一个nuget包),你可以直接反序列化为数据表。
DataTable dt =(DataTable)JsonConvert.DeserializeObject(myJsonString,( typeof (DataTable)));
唯一可能的问题是它会将所有字段反序列化为字符串对象。
I need to create web service web api and i need to create CRUD and menu but I have the data as json file , I need to Convert the data from file.json to datatable in sql server and convert the data from sql server to file .json automatically . because when the data become as data in tabe than it will be easy to create CRUDE in MVC web api C#
Is any one has any idea , please help
What I have tried:
Nothing.
Deserialize your json collection:
Deserialize a Collection[^]
After that, write a method that converts your deserialized objects into a datatable, and Bob's your uncle.
BTW, if you use the netwtonsoft json.net library (a nuget package), you can deserialize directly to a datatable.
DataTable dt = (DataTable)JsonConvert.DeserializeObject(myJsonString, (typeof(DataTable)));
The only possible issue is that it will deserialize all of the fields as string object.
这篇关于将数据从file.json转换为sqlserver中的datatable,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!