JSONObject 到 String Android
如何在没有这些括号的情况下将 "{hello1: hi, hello2: hey}"
这样的 JSONObject 转换为 "hello1: hi, hello2: hey"
{ } ?
我知道有机会使用 JSONObject.tostring 但随后我会得到一个带括号的字符串。
谢谢大家。
how can I convert a JSONObject like "{hello1: hi, hello2: hey}"
to "hello1: hi, hello2: hey"
without these brackets { }
?
I know that there is a opportunity to use JSONObject.tostring but then I'll get a string with the brackets.
Thanks all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需进行子字符串或字符串替换即可。
伪子字符串示例:
伪字符串替换示例:
Just do a substring or string replace.
Pseudo substring Example:
Pseudo string replace Example:
假设您实际上想做的事情比您的问题建议的更复杂,并且您可以对将使用的 JSON 做出一些假设,您可以执行如下操作来获取您想要的任何输出格式。
话又说回来,我可能读得太多了(在这种情况下@ProgrammerXR 的答案就可以了)。
Assuming that you actually want to do something more elaborate than your question suggests and you can make some assumptions about the JSON you'll be working with, you could do something like the following to get any output format you'd like.
Then again, I might have read into this too much (in which case @ProgrammerXR's answer would do the trick).