json 数据解析


import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

 

模拟数据

JSONObject  xCol = {"label":"招聘部门","fieldtype":"VALUE_TYPE_VARCHAR","fx":"","value":"ITEM_RECRUITMENT_DEPARTMENT"};
JSONArray  yCols = [{"label":"拟招人数","fieldtype":"VALUE_TYPE_NUMBER","fx":"sum","value":"ITEM_RECRUITMENT_NUMBER"}];

 

JSONObject jsonX = JSONObject.fromObject(xCol);
JSONArray jsonArrayY = JSONArray.fromObject(yCols);
JSONObject jsonY = JSONObject.fromObject(jsonArrayY.get(0));
   
String keyX = jsonX.names().getString(0);
String keyY = jsonY.names().getString(0);
String xColName = jsonX.getString(keyX);
String yColName = jsonY.getString(keyY);

 

结果

xColName = "招聘部门"
yColName = "拟招人数"

你可能感兴趣的:(json解析)