我正在尝试处理有时对于图像标签具有不同格式的JSON:
"image": [
"https:\/\/tmbidigitalassetsazure.blob.core.windows.net\/secure\/RMS\/attachments\/37\/1200x1200\/Cheesy-Cauliflower-Breadsticks_EXPS_THCOMS17_207460_B09_08_3b.jpg",
[
"https:\/\/cdn3.tmbi.com\/toh\/GoogleImages\/Cheesy-Cauliflower-Breadsticks_EXPS_THCOMS17_207460_B09_08_3b.jpg"
],
[
"https:\/\/cdn3.tmbi.com\/toh\/GoogleImagesPostCard\/Cheesy-Cauliflower-Breadsticks_EXPS_THCOMS17_207460_B09_08_3b.jpg"
]
],
或
"image": "http://someimage"
或
"image": [
"https://alldayidreamaboutfood.com/wp-content/uploads/2017/06/Garlic-Parmesan-Wings.jpg"
]
最后
"image": {
"@type": "ImageObject",
"url": "http://cdn.ampproject.org/leader.jpg",
"height": 200,
"width": 200
},
我的代码具有:
@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
private String[] image;
此方法似乎适用于第二个和第三个示例,但第一个示例抛出异常:
Cannot deserialize instance of `java.lang.String` out of START_ARRAY token
有关如何处理此类变体的任何提示?