com.alibaba.fastjson.JSONException: not match : - =异常

在使用fastjson来将json数据转换成model时出现如下异常:

wKiom1O7mBiD_iRjAAU-358vdLI086.jpg

public class TestDemo {

	public static void main(String[] args) throws IOException {
		String responseData = 
			"{\"code\":0,\"errorDescription\":\"操作成功\"," +
			"\"dataObject\":{\"imgUrl\":\"https://mobilecodec.alipay.com/show.htm" +
			"?code=pvv4z94z8tnazwek0c&picSize=M\",\"expireSecond\":1800}}";
		RestModel restModel = (RestModel) JsonUtil.jsonToObject(responseData,RestModel.class);
		String str = restModel.getDataObject().toString();
		ZpSpreadInfoByAlipayRsp zpSpreadInfoByAlipayRsp = (ZpSpreadInfoByAlipayRsp) JsonUtil
				.jsonToObjectByRest(str,ZpSpreadInfoByAlipayRsp.class);
		String imgUrl = zpSpreadInfoByAlipayRsp.getImgUrl();
		System.out.println(imgUrl);
	}
}


public class JsonUtil {
	public static Object jsonToObject(String json, Class cls)
		throws JsonGenerationException, JsonMappingException, IOException {
		Object obj = null;
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
		obj = mapper.readValue(json, cls);
		return obj;
	}
}


你可能感兴趣的:(代码,public)