大佬教程收集整理的这篇文章主要介绍了com.alibaba.fastjson.JSONException: not match : - =异常,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在使用fastjson来将json数据转换成model时出现如下异常:
publicclassTestDemo{ publicstaticvoidmain(String[]args)throwsIOException{ StringresponseData= "{\"code\":0,\"errorDescription\":\"操作成功\","+ "\"dataObject\":{\"imgurl\":\"https://mobilecodec.alipay.com/show.htm"+ "?code=pvv4z94z8tnazwek0c&picSize=M\",\"expireSecond\":1800}}"; RestModelrestModel=(RestModel)JsonUtil.jsonToObject(responseData,RestModel.class); Stringstr=restModel.getDataObject().toString(); ZpSpreadInfoByAlipayRspzpSpreadInfoByAlipayRsp=(ZpSpreadInfoByAlipayRsp)JsonUtil .jsonToObjectByRest(str,ZpSpreadInfoByAlipayRsp.class); Stringimgurl=zpSpreadInfoByAlipayRsp.getimgurl(); System.out.println(imgurl); } } publicclassjsonUtil{ publicstaticObjectjsonToObject(Stringjson,Classcls) throwsJsonGenerationException,JsonMappingException,IOException{ Objectobj=null; ObjectMappermapper=newObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES,truE); obj=mapper.readValue(json,cls); returnobj; } }
以上是大佬教程为你收集整理的com.alibaba.fastjson.JSONException: not match : - =异常全部内容,希望文章能够帮你解决com.alibaba.fastjson.JSONException: not match : - =异常所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。