Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Klaxon 将对象转换为 JSON 对象,但它会创建一个像这样的对象:
data class Welcome( val text: String )
结果是:
{ text: "some value" }
但我想要类似的东西
"Welcome"{ text: "Some value" }
作为解决方案,我改用 org.json 并使用以下代码来获得我想要的结果:
val jsonString = """ { "blog": { "title": "$title", "content": "$content" } } """ var jsonBlogObject = JSONObject(jsonString) jsonBlogObject.put("someting", "some value")