java如何使用映射器从包含多个引用单元的JSON字符串中获取对象列表?
我的要求是获取所有选定列并将其作为Json字符串保存到数据库中,然后再次将它们转换回对象列表并返回到UI, 我的Json看起来像这样,我想要维度列表,我如何做到这一点?请推荐我
{
"dimensions": [{
"displayName": "Advertised Products",
"name": "Product",
"selectable": false,
"multipleSelect": true,
"hasFavorites": true,
"showCancel": false,
"showClear": false,
"hasCustomObjects": true,
"isPrimary": true,
"searchable": true,
"editable": true
}, {
"displayName": "Companion Products",
"name": "Product",
"selectable": false,
"multipleSelect": true,
"hasFavorites": true,
"showCancel": false,
"showClear": false,
"hasCustomObjects": true,
"isPrimary": true,
"searchable": true,
"editable": true
}, {
"displayName": "Fsp Products",
"name": "Product",
"selectable": false,
"multipleSelect": true,
"hasFavorites": true,
"showCancel": false,
"showClear": false,
"hasCustomObjects": true,
"isPrimary": true,
"searchable": true,
"editable": true
}]
}
# 1 楼答案
创建具有维度对象引用、setter和getter的DimensionTO pojo
使用对象映射器读取尺寸列表
现在我们可以迭代dimensionList以获得每个维度对象的值