How can we post following json array in sql server using c#?
{
"sname" : ["<font color='red'> AneeshYadav </font>", "<font color='red'> AdityaMadan </font>", "<font color='red'> DrishtiThakur </font>", "<font color='red'> IshaanSahay </font>"],
"admno" : ["1357", "1414", "1442", "4184"],
"class" : ["1795", "1795", "1795", "1795"],
"sms" : ["0", "1", "1", "1"],
"att" : ["Not Posted", "Not Posted", "Not Posted", "Not Posted"],
"tra" : ["on", "on", "on", "on"]
}
Sure you can.
Note that varchar field has a size of 8000 character max. As of 2005 varchar(MAX) can be used which (by msdn) claims to be 2^31-1 which is 2147483647 (2.14 billion). However, you need to use special indexing if you want to use keywords
contains
andlike
.
However it will be way more efficient to use Mongo, Redis, Raven instead.
This may not be the best way but hopefully it will help. Convert the json string to a DataTable ( mainly for the structure). Then iterate through the data in the datatable and save it to the db.
using Newtonsoft.Json;
string json = "...<json data>...";
// Convert to DataTable.
// Deserialize the JSon value and assign it to datatable
DataTable dtValue = (DataTable)JsonConvert.DeserializeObject(json,typeof(DataTable)));
Just a note as well, check your json object formatting.
如果您安装 Sql Server 2016 CTP3,您可以使用 OPENJSON,请参阅在 Sql Server 2016 中导入 JSON
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.