#随手记#fastjson 解析数据
来源:互联网 发布:淘宝推广能做运营么 编辑:程序博客网 时间:2024/06/02 01:33
发生错误,JSON.parseObject default constructor not found. class com.lottery.app.contractTemplet.FAQ错误原因,缺少默认构造函数,修改bean文件,添加默认构造方法,问题解决。以下为错误案例:
public class FAQ {private String question;private String answer;private String id;public FAQ(String id,String question, String answer) {super();this.question = question;this.answer = answer;this.id = id;}public String getQuestion() {return question;}public void setQuestion(String question) {this.question = question;}public String getAnswer() {return answer;}public void setAnswer(String answer) {this.answer = answer;}public String getId() {return id;}public void setId(String id) {this.id = id;}}JSONObject objK = new JSONObject();try {JSONArray arrayK = new JSONArray();FAQ f1 = new FAQ("01", "机器如何操作?", "请仔细阅读说明书,或致电我们!");arrayK.put(new JSONObject(JSON.toJSONString(f1)));FAQ f2 = new FAQ("02", "机器出现故障如何处理?", "请仔细阅读说明书,或致电我们!");arrayK.put(new JSONObject(JSON.toJSONString(f2)));objK.put("list", arrayK);contractTemplet.setContractFile(objK.toString());} catch (JSONException e1) {e1.printStackTrace();}String file = contractTemplet.getContractFile();try {JSONObject obj = new JSONObject(file);JSONArray array = obj.getJSONArray("list");for (int i = 0; i < array.length(); i++) {JSONObject te=array.getJSONObject(i);FAQ group2 = JSON.parseObject(te.toString(), FAQ.class);if (group2 == null) {return JsonUtil.getReturnJson(0, "常见问题错误");}}} catch (JSONException e) {e.printStackTrace();}catch (com.alibaba.fastjson.JSONException e) {//抛出异常!!!e.printStackTrace();}
阅读全文
0 0
- #随手记#fastjson 解析数据
- fastjson数据解析实例
- FastJson数据解析
- fastjson解析json数据
- fastjson解析数据
- fastjson解析JSON数据
- 数据解析(三):FastJson
- fastJson解析Json数据
- fastjson解析json数据
- Json数据解析之Fastjson
- 使用FastJson解析Json数据
- 使用FastJson解析Json数据
- 使用FastJson解析Json数据
- 使用fastjson解析json数据
- 使用FastJson解析Json数据
- 使用FastJson解析Json数据
- SparkCore解析json数据fastjson
- 使用FastJson解析Json数据
- 【每天一点Linux】Linux下进度条的实现
- 十六、性能优化
- centos学习:探一探apache工作模式之prefork worker event
- java实现位图排序算法《编程珠玑》第一章笔记
- iOS中文参数的URL地址URLEncode转码
- #随手记#fastjson 解析数据
- 十七、不使用ES6编写React应用
- 多表不连表处理方法,数据为多选数据处理方法
- solr6.6 了解managed-schema
- 十八、不使用JSX编写React应用
- nio 1
- 矢量数据下载【道路路网(公路、铁路)、水系、建筑物轮廓、地名等等】
- ProgressDialog使用,让进度条显示出Mb大小
- 嵌入式学习心得体会