基于C#的接口自动化测试(二)

时间:2021-08-19 20:17:30

Json多重数据处理方法II:jobj直接向后调用即可

var CommoditSKU = jobj["data"]["Orders"][j]["Goods"][]["GoodsName"];

用:分隔的字符串转字典:

 public static Dictionary<string, object> StringConvertDictionary(string str)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
string[] strarr;
foreach (var i in str.Split('\r'))
{
strarr = i.Split(':');
dict.Add(strarr[], strarr[]);
}
return dict;
}

读取配置文件节点:

//引入命名空间
using System.Configuration;
ConfigurationSettings.AppSettings["节点名"]