糟透了. JSON.他的方法? [英] Grails. JSON. his methods?
本文介绍了糟透了. JSON.他的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我整夜忙于寻找有关如何在Grails
中使用JSON
的信息.我发现,在JSON closure
中,我们只能使用一种方法-array
-不能使用其他方法.是真的吗?
I was up all night looking for information on how to use JSON
in Grails
. And I found the information that in JSON closure
, we can use only one method - array
- no other. is it true?
以及下一个小问题:
我在这里找到: http://www.jiramot. info/mini-guide-to-rendering-json-with-grails 示例:
render(contentType:‘text/json’){
collection{
pair(name:‘value’)
pair(name:‘value1′)
}
}
将呈现为:
{collection:[{"name":"value"},{"name":"value1"}]
但是当我尝试这样做时,我会得到以下结果:
but when i try do it, i have this result:
{"collection":{"pair":{"name":"value1"}}}
我们能得出什么结论? 我在网站上做了一些错误或错误的例子吗?
What conclusion can we do? i do some wrong or wrong example on site?
推荐答案
尝试
render(contentType:‘text/json’){
collection {
array {
pair(name:"value")
pair(name:"value1")
}
}
}
这篇关于糟透了. JSON.他的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文