【发布时间】:2017-06-12 10:47:56
【问题描述】:
我想在我的应用程序中使用 json builder 进行类似的操作
new JsonBuilder() {
persons.collect{
[
name: it.name,
age: it.age,
companies: [{
company1: it.company //The company comes from person object.
},
{
company2: it.company
}
]
]
}
}
这里在访问公司空指针时抛出异常,因为它没有考虑person迭代器。有没有其他方法可以这样做??
【问题讨论】:
标签: groovy jsonbuilder