-
jsonjar包及使用方式.zip下载
资源介绍
在java开发中使用json字符串时,可以将字符串转为对象,在进行开发处理
// 找到每行 string= {"end":"2019-05-20 06:31:04","level":-81,"mac":"D0:76:E7:EB:67:DE","start":"2019-05-20 06:29:29"}
int index = string.indexOf("mac");
//获取没有分隔符的mac标志 prefix
String key = string.substring(index + 6, index + 14).replace(":", "");
//每行加入 brand 节点,写入到文中
JSONObject jsobj=JSONObject.fromObject(string);
StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append( jsobj.getString("mac")+",")
.append(jsobj.getString("start")+",")
.append(jsobj.getString("end")+",")
.append(key+",").append( brandMap.get(key)+"\n");