本文共 10452 字,大约阅读时间需要 34 分钟。
{"errorCode":"","success":true,"message":"","data":{"scoreId":"98","templateId":"","title":"新建权重评分表-auto-test","type":"1","state":"2","containers":[{"id":"692","text":"维度1","components":[{"id":"2196","text":"第一个指标","percent":"25","type":"1","options":[{"id":"6978","text":"好","score":"100","sort_num":1},{"id":"6979","text":"较好","score":"80","sort_num":2},{"id":"6980","text":"一般","score":"60","sort_num":3},{"id":"6981","text":"较差","score":"40","sort_num":4},{"id":"6982","text":"差","score":"0","sort_num":5}]},{"id":"2197","text":"第二个指标","percent":"25","type":"2","options":[{"id":"6983","text":"评分标准1","score":"100","sort_num":1}]}]},{"id":"693","text":"维度2","components":[{"id":"2198","text":"第三个指标","percent":"25","type":"2","options":[{"id":"6984","text":"评分标准2","score":"100","sort_num":1}]},{"id":"2199","text":"第四个指标","percent":"25","type":"1","options":[{"id":"6985","text":"好","score":"100","sort_num":1},{"id":"6986","text":"较好","score":"80","sort_num":2},{"id":"6987","text":"一般","score":"60","sort_num":3},{"id":"6988","text":"较差","score":"40","sort_num":4},{"id":"6989","text":"差","score":"0","sort_num":5}]}]}]}}
{
"645(题目的id)":{"id":"2546(选项的id)","percent":"25(分值,固定值)"}, "646(同上)":{"id":"2551(同上)","percent":"24.75(同上)","value(该参数只有在题目的type=2的时候才会出现)":"99(分值,固定值)"} }
{"success":true,"message":"","errorCode":"","data":[{"submit_state":"0","score_id":"f5","travel_id":"5","travel_title":"auto-test-zyj1502356486388","inspect_time":"2033-08-23","category_codes":"2266","suggest_content":"","my_score":"0","categoryName":"商业包装设计与施工","scoreData":{"fbScoreId":"f5","templateId":"","title":"新建权重评分表-auto-test-zyj","type":1,"containers":[{"id":"8","text":"维度1","components":[{"id":"14","text":"第一个指标","percent":"25","type":"1","options":[{"id":"38","text":"好","score":"100","sort_num":1},{"id":"39","text":"较好","score":"80","sort_num":2},{"id":"40","text":"一般","score":"60","sort_num":3},{"id":"41","text":"较差","score":"40","sort_num":4},{"id":"42","text":"差","score":"0","sort_num":5}],"select":""},{"id":"15","text":"第二个指标","percent":"25","type":"2","options":[{"id":"43","text":"评分标准1","score":"100","sort_num":1}],"select":""}]},{"id":"9","text":"维度2","components":[{"id":"16","text":"第三个指标","percent":"25","type":"2","options":[{"id":"44","text":"评分标准2","score":"100","sort_num":1}],"select":""},{"id":"17","text":"第四个指标","percent":"25","type":"1","options":[{"id":"45","text":"好","score":"100","sort_num":1},{"id":"46","text":"较好","score":"80","sort_num":2},{"id":"47","text":"一般","score":"60","sort_num":3},{"id":"48","text":"较差","score":"40","sort_num":4},{"id":"49","text":"差","score":"0","sort_num":5}],"select":""}]}]},"travelDetail":{"travel_id":"5","score_id":"f5","travel_title":"auto-test-zyj1502356486388","company_name":"上海东方雨虹防水技术有限责任公司","supplier_type":"2","tax_qualify":"2","organizer_id":"195104","inspect_time":"2033-08-23","scoreName":"新建权重评分表-auto-test-zyj","supplierTypeName":"代理商","taxQualifyName":"小规模纳税人","organizerName":"125","Teams":"zyj账号01、zyj账号02","Locations":[{"name":"办公室","remark":"备注1"},{"name":"地点一","remark":"备注2"}],"QualifyFiles":[{"name":"营业执照","remark":"备注3"},{"name":"地点二","remark":"备注4"}]},"travelPhoto":[],"photoDescription":{"1":[{"address":"地点一"},{"address":"办公室"}],"2":[{"address":"地点二"},{"address":"营业执照"}]},"photo_count":0,"score_item_total_count":"4"},{"submit_state":"0","score_id":"f4","travel_id":"4","travel_title":"auto-test-zyj1502351094326","inspect_time":"2033-08-23","category_codes":"2266","suggest_content":"","my_score":"0","categoryName":"商业包装设计与施工","scoreData":{"fbScoreId":"f4","templateId":"","title":"新建权重评分表-auto-test-zyj","type":1,"containers":[{"id":"6","text":"维度1","components":[{"id":"10","text":"第一个指标","percent":"25","type":"1","options":[{"id":"26","text":"好","score":"100","sort_num":1},{"id":"27","text":"较好","score":"80","sort_num":2},{"id":"28","text":"一般","score":"60","sort_num":3},{"id":"29","text":"较差","score":"40","sort_num":4},{"id":"30","text":"差","score":"0","sort_num":5}],"select":""},{"id":"11","text":"第二个指标","percent":"25","type":"2","options":[{"id":"31","text":"评分标准1","score":"100","sort_num":1}],"select":""}]},{"id":"7","text":"维度2","components":[{"id":"12","text":"第三个指标","percent":"25","type":"2","options":[{"id":"32","text":"评分标准2","score":"100","sort_num":1}],"select":""},{"id":"13","text":"第四个指标","percent":"25","type":"1","options":[{"id":"33","text":"好","score":"100","sort_num":1},{"id":"34","text":"较好","score":"80","sort_num":2},{"id":"35","text":"一般","score":"60","sort_num":3},{"id":"36","text":"较差","score":"40","sort_num":4},{"id":"37","text":"差","score":"0","sort_num":5}],"select":""}]}]},"travelDetail":{"travel_id":"4","score_id":"f4","travel_title":"auto-test-zyj1502351094326","company_name":"上海东方雨虹防水技术有限责任公司","supplier_type":"2","tax_qualify":"2","organizer_id":"195104","inspect_time":"2033-08-23","scoreName":"新建权重评分表-auto-test-zyj","supplierTypeName":"代理商","taxQualifyName":"小规模纳税人","organizerName":"125","Teams":"zyj账号01、zyj账号02","Locations":[{"name":"办公室","remark":"备注1"},{"name":"地点一","remark":"备注2"}],"QualifyFiles":[{"name":"营业执照","remark":"备注3"},{"name":"地点二","remark":"备注4"}]},"travelPhoto":[],"photoDescription":{"1":[{"address":"地点一"},{"address":"办公室"}],"2":[{"address":"地点二"},{"address":"营业执照"}]},"photo_count":0,"score_item_total_count":"4"}]}
是一个无序的键/值对集合。
是一个有序的序列值。
这里直接放出处理的源码:
import java.util.HashMap;import java.util.Map;import org.json.*; System.out.println("test................................................................"); //提取返回值作为变量response_data String response_data = prev.getResponseDataAsString(); //解析json JSONObject data_obj = new JSONObject(response_data); JSONArray jsonarray = data_obj.getJSONArray("data"); JSONObject scoreData = null; int id = Integer.parseInt(vars.get("travel_id")); System.out.println("id="+id); for (int i = 0; i < jsonarray.length(); i++) { JSONObject jsonobj = jsonarray.getJSONObject(i); System.out.println(jsonarray.optString(i)); System.out.println(jsonobj.getInt("travel_id")); System.out.println(jsonobj.getString("travel_title")); int travle_id = jsonobj.getInt("travel_id"); if(travle_id==id){ scoreData = jsonobj.getJSONObject("scoreData"); } } JSONArray containers = scoreData.getJSONArray("containers"); Map data = new HashMap(); for (int i = 0; i < containers.length(); i++){ JSONArray component_ary = containers.getJSONObject(i).getJSONArray("components"); for (int j = 0; j < component_ary.length(); j++){ System.out.println(component_ary.optString(j)); System.out.println(component_ary.getJSONObject(j).get("id")); String data_id = component_ary.getJSONObject(j).get("id").toString(); JSONArray options = component_ary.getJSONObject(j).getJSONArray("options"); String score_id = options.getJSONObject(0).get("id").toString(); System.out.println(options.getJSONObject(0).get("id")); Map score = new HashMap(); score.put("id", score_id); score.put("percent", "25"); if(component_ary.getJSONObject(j).getInt("type")==2){ score.put("value", "99"); } System.out.println(score); data.put(data_id, score); System.out.println(data); } } //将map类型转换为json字符 JSONObject putdata = new JSONObject(data); System.out.println(putdata); //将putdata输出到jmeter变量里 vars.put("putdata", JSONObject.valueToString(putdata));
转载地址:http://xakix.baihongyu.com/