【发布时间】:2017-02-24 11:25:14
【问题描述】:
如何将此 JSON 映射到对象?
{"d":"[{\"Key\":\"3\",\"ExternalKey\":\"143234A\",\"Name\":\"cup of juice\",\"Litres\":\"2 litres\",\"Date\":\"2016-10-06T08:32:27\",\"Capacity\":5.4900,\"CapacityType\":\"%\"}, {\"Key\":\"3\",\"ExternalKey\":\"143234A\",\"Name\":\"cup of milk\",\"Litres\":\"2.4 litres\",\"Date\":\"2016-10-06T08:32:27\",\"Capacity\":1667.6100,\"CapacityType\":\"M\"}]"}
我尝试过使用 HashMap,但它只是将“d”作为字符串,其余作为带有一个元素的 String 对象
【问题讨论】:
-
定义一个匹配json结构的类
-
我有,还是没有正确映射
-
它给了我这个错误:com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize java.util.ArrayList 的实例 out of VALUE_STRING token at [Source: {"d":"[{ \"Key\":\"3\"......等
标签: java android json serialization gson