您可以使用
JSONDeserializer.use()方法告诉它如何反序列化数组以及数组中的每个对象(在这种情况下为class)
ProductInformation。product_id属性与flexjson期望的标准命名不匹配,因此您在对象上的属性将需要在其下划线。
String products= "[{"product_id": "123","name":"stack"},{"product_id": "456","name":"overflow"}]";List<ProductInformation> productInfoList = new JSONDeserializer<List<ProductInformation> >() .use(null, ArrayList.class) .use("values",ProductInformation.class) .deserialize(products);for(ProductInformation productInformation : productInfoList){ System.out.println(productInformation.getProduct_id();}文档的反序列化部分中的
“无需训练轮的反序列化”部分将详细介绍其他情况,以考虑JSON字符串中是否不包含类型信息。



