在使用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; } }