1.登录海康的管理平台,测试API,获取返回的Json字符串
2.将json字符串贴到如下网站中: http://www.bejson.com/convert/json2csharp/ ,将生成的类拷贝下来,贴到自己开发程序代码中(假设类名为Root);
3.打开 https://www.newtonsoft.com/json ,下载Newtonsoft.Json.DLL
4.程序中使用组件和类
using Newtonsoft.Json;
5.值获取
//调用API获得json字符串
string url = "/artemis//api/resource/v1/face/single/add";
byte[] result = HttpUtillib.HttpPost(url, postvalue, 15);
//转换Json 字符串实例化Root类,
Root rt = JsonConvert.DeserializeObject<Root>(System.Text.Encoding.UTF8.GetString(result));
//获取json字符串中的值
string val = rt.msg
//如果Json中返回的data值是一个集合,则
for (int i = 0; i < rt.data.Count; i++)
string location = rt.data[i].location