我目前正在使用com.google.gson api(使用gson-2.8.5版本)的JsonObject和JsonParser来解析和读取输入JSON的值。
我有 JSON 归档,例如 smaple,"resultCode":"SUCCESS",当我尝试从 json 读取相同的值时,它给出的结果为""SUCCESS"".
我正在阅读的每个值都带有双“”,不知道为什么?您可以参考我的调试屏幕的下面屏幕。
我是 Json 和解析器的新手,这是默认行为吗?
我期待"SUCCESS","S"不像
我
在下图中突出显示的"00000000"那样""SUCCESS""。""S""""00000000""
请分享我们如何获得字符串的绝对值而不使用“””双引号字符串的任何想法,它会导致我的字符串比较失败。
String response_result = "{\"response\": {\"head\": {\"function\": \"acquiring.order.create\",\"version\": \"2.0\",\"clientId\": \"201810300000\",\"reqMsgId\": \"56805892035\",\"respTime\": \"2019-09-13T13:18:08+08:00\"},\"body\": {\"resultInfo\": {\"resultCode\": \"SUCCESS\",\"resultCodeId\": \"00000000\",\"resultStatus\": S,\"resultMsg\": \"SUCCESS\"},\"acquirementId\": \"2018080834569894848930\",\"merchantTransId\": \"5683668701112717398\",\"checkoutUrl\": \"http://localhost:8081/crm/operator/operator-search-init.action\"}},\"signature\":\"d+TUYLvt1a491R1e6aO8i9VwXWzVhfNgnhD0Du74f4RgBQ==\"}";
HttpInvoker.Result result = i.new Result(200, response_result);
JsonObject jo = new JsonParser().parse(response_result).getAsJsonObject();
String resultCode = jo.get("response").getAsJsonObject().get("body").getAsJsonObject().get("resultInfo").getAsJsonObject().get("resultCode").toString();
String resultCodeId = jo.get("response").getAsJsonObject().get("body").getAsJsonObject().get("resultInfo").getAsJsonObject().get("resultCodeId").toString();
String resultStatus = jo.get("response").getAsJsonObject().get("body").getAsJsonObject().get("resultInfo").getAsJsonObject().get("resultStatus").toString();
String checkoutUrl = jo.get("response").getAsJsonObject().get("body").getAsJsonObject().get("checkoutUrl").toString();
if ( RESULT_CODE_GCASH_SUCCESS.equals(resultCode) …Run Code Online (Sandbox Code Playgroud)