我有这个看起来像这样的JSON
[
{
"name": "annotation-1",
"label": "Annotation",
"value": {
"drawing": {
"objects": [
{
"type": "line",
"originX": "left",
"originY": "top",
"left": 0,
"top": 664,
"width": 0,
"height": 0,
"fill": "",
"stroke": "",
"strokeWidth": 0,
"strokeDashArray": null,
"strokeLineCap": "butt",
"strokeLineJoin": "miter",
"strokeMiterLimit": 10,
"scaleX": 1,
"scaleY": 1,
"angle": 0,
"flipX": false,
"flipY": false,
"opacity": 1,
"shadow": null,
"visible": false,
"clipTo": null,
"backgroundColor": "",
"fillRule": "nonzero",
"globalCompositeOperation": "source-over",
"transformMatrix": null,
"skewX": 0,
"skewY": 0,
"x1": 0,
"x2": 0,
"y1": 0,
"y2": 0
}
],
"_ko_subscr_1": true
},
"src": "00005-notification_icon.png",
"_ko_subscr_1": true
},
"type": "annotation",
"css": "",
"allowUserUpload": "yes",
"helpText": "",
"validations": [
{
"type": "required",
"details": {
"active": true,
"message": "Required!"
}
}
],
"initialValue": "",
"visible": true,
"draggable": false,
"displayWidth": "500",
"width": 600,
"height": 664.45182724252493,
"signatureLine": {
"width": "",
"color": "",
"visible": false,
"offsetX": "",
"offsetY": ""
},
"drawingBrush": {
"width": "6",
"color": "#ffff00"
},
"displayLogic": {
"type": "show",
"rules": {}
},
"guid": "c382eb19-463f-4c5d-bd88-6c15d2b361e5"
},
{
"name": "heading-1",
"value": "Heading",
"type": "heading",
"css": "",
"helpText": "Enter heading",
"size": "Large",
"displayLogic": {
"type": "show",
"rules": {}
},
"guid": "9fa79f52-228e-45fd-8137-1ee398c72696"
}
]
我基本上为每个JSON对象创建了一个类,并使用GSON解析JSON。我的问题是“值”既可以是字符串也可以是对象。如何确定何时返回值以及何时返回“value”对象?我只是在包含“value”元素的类中创建一个字符串变量,如果“value”是一个字符串,则返回该变量吗?