如何从Kotlin中的String创建JSONObject? [英] How to create a JSONObject from String in Kotlin?
本文介绍了如何从Kotlin中的String创建JSONObject?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将字符串{\"name\":\"test name\", \"age\":25}
转换为JSONObject
I need to convert a string {\"name\":\"test name\", \"age\":25}
to a JSONObject
推荐答案
也许我误解了这个问题,但听起来您已经在使用org.json了,这引起了关于为什么的问题
Perhaps I'm misunderstanding the question but it sounds like you are already using org.json which begs the question about why
val answer = JSONObject("""{"name":"test name", "age":25}""")
不是最好的方法吗? JSONObject的内置功能出了什么问题?
wouldn't be the best way to do it? What was wrong with the built in functionality of JSONObject?
这篇关于如何从Kotlin中的String创建JSONObject?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文