开发者

toString with JSON Object

when creating a string from a JSON object, it is constructing the resulting string like this

"comments": "[
 {\"id\":2,
  \"postType\":\"COMMENT_TYPE\",
 开发者_高级运维 \"subject\":\"RE: sadasds\",
  \"body\":\"test comment submission\",
  \"tags\":\"\",
  \"media\":[],
  \"comments\":\"[]\"}
]"

including the \" which makes it difficult for me to include in an existing JSON object


You're going to have to explain the situation you're in, and the code you're using

I just tried this:

@Grab( group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15')
import net.sf.json.*

def o = [integer:1, bool: true] as JSONObject 
println o.toString()

And it (as expected) gave me the output:

{"integer":1,"bool":true}

What version of Groovy are you using? Which JSON library are you using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜