Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 基于类反序列化json时发生异常,该类内部有接口类型_Java_Json_Gson - Fatal编程技术网

Java 基于类反序列化json时发生异常,该类内部有接口类型

Java 基于类反序列化json时发生异常,该类内部有接口类型,java,json,gson,Java,Json,Gson,我得到了json文件和第三方类:Dealer和interface IDealerAttributes(我不能更改任何一个); (我删除包名和导入以简化代码) 您可以将其映射到地图列表,然后使用BeanMapper(如获取更多信息的错误消息)您可以将其映射到地图列表,然后使用BeanMapper(如获取更多信息的错误消息)您可以给出更详细的说明吗?谢谢你能给我一些更详细的说明吗?谢谢 JSON file { "serviceURL": "com.mycompany.servic

我得到了json文件和第三方类:Dealer和interface IDealerAttributes(我不能更改任何一个); (我删除包名和导入以简化代码)


您可以将其映射到地图列表,然后使用BeanMapper(如获取更多信息的错误消息)

您可以将其映射到地图列表,然后使用BeanMapper(如获取更多信息的错误消息)

您可以给出更详细的说明吗?谢谢你能给我一些更详细的说明吗?谢谢 JSON file { "serviceURL": "com.mycompany.serviceURL", "dealerAttributes": [ { "language": "language0", "dealerAttributeName": "dealerAttributeName0", "updateDate": 0 }, { "language": "language1", "dealerAttributeName": "dealerAttributeName1", "updateDate": 1 } ] } class Dealer { private String serviceURL; private List dealerAttributes; public Dealer() { dealerAttributes = new ArrayList(); } //Getters and Setters... } public interface IDealerAttributes { public String getLanguage(); public String getDealerAttributeName(); public long getUpdateDate(); } gson.fromJson(jsonObj.toString(), Dealer.class); Exception unmarshalling json String into Object: com.google.gson.JsonParseException: The JsonDeserializer com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@60e26ffd failed to deserialize json object [{"language":"language0","dealerAttributeName":"dealerAttributeName0","updateDate":0},{"language":"language1","dealerAttributeName":"dealerAttributeName1","updateDate":1}] given the type java.util.List public class DealerAttributes implements IDealerAttributes { private String language; private String dealerAttributeName; private long updateDate; public DealerAttributes() { } //Getters and Setters... }
gson.registerTypeAdapter(MyType.class, new MyType());`