3 回答

TA貢獻1824條經驗 獲得超5個贊
JSONobject.remove("jsonErrorResponse")
返回被移除的東西。您正在調用toString
您剛剛“刪除”的部分。
簡單地不要鏈接方法調用。
JSONobject.remove("jsonErrorResponse"); String newJson = JSONobject.toString()

TA貢獻1841條經驗 獲得超3個贊
由于您正在處理,因此JSONobject您正在從該對象中刪除內容。
您需要調用toString().JSONobject
String str = "{\"mandator\":\"GB0010001\",\"debitAccount\":\"81884\",\"creditAccount\":\"82918\",\"trustedBeneficiary\":\"false\",\"localCurrencyAmount\":35,\"transactionReference\":\"omega7.1.1\",\"debitAccountASPSP\":\"t24\",\"currencyAmount\":35,\"executionDate\":\"20180102\",\"creditAccountASPSP\":\"t24\",\"transactionType\":\"Contactless payment\",\"trustedPSP\":\"false\",\"jsonErrorResponse\":{\"errorCount\":0,\"errors\":[]},\"currency\":\"USD\",\"company\":\"GB0010001\"}"
JSONObject jsonObject = new JSONObject(str);
jsonObject.remove("jsonErrorResponse");
jsonObject.toString();
添加回答
舉報