C#遍历json内容,并添加到DataTable里面作为列
直接看代码,不啰嗦!
简单易懂,希望对你有帮助,若有帮助,给个赞吧!
先看json格式
{“ProdSN”:"{SerialNumber}",“EqpID”:"{EqpID}",“Parameter”:[{“ParaName”:“overallResult”,“ParaValue”:"{overallResult}"},{“ParaName”:“errCode”,“ParaValue”:"{errCode}"},{“ParaName”:“startTime”,“ParaValue”:"{startTime}"},{“ParaName”:“stopTime”,“ParaValue”:"{stopTime}"},{“ParaName”:“testerID”,“ParaValue”:"{testerID}"}]}
代码实现
需要引用:using Newtonsoft.Json.Linq;
string[] lines = null;
string Path = System.AppDomain.CurrentDomain.BaseDirectory + "\\CONFIGURATION_TABLE";
string strFullJosnPath = Path + "\\" + "Trackout_test.json";
if (File.Exists(strFullJosnPath))
{
lines = File.ReadAllLines