如何将JSONObject转换"{hello1: hi, hello2: hey}"为"hello1: hi, hello2: hey"没有这些括号{ }?
我知道有机会使用JSONObject.tostring然后我会得到一个带括号的字符串.
谢谢大家.
Mar*_*oek 14
只需做一个子串或字符串替换.
伪子串示例:
JSONObject a = new JSONObject("{hello1: hi, hello2: hey}");
String b = a.toString().substring(1, a.toString().length() - 1);
Run Code Online (Sandbox Code Playgroud)
伪字符串替换示例:
JSONObject a = new JSONObject("{hello1: hi, hello2: hey}");
String b = a.toString().replace("{", "");
String c = b.toString().replace("}", "");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50171 次 |
| 最近记录: |