这个tacos.getIngredient是一个set方法
而它的泛型是LIst(String),它把这个对象以字符的形式存入
我可以直接改成List(Ingredient),它就不报错了,但是程序不报错,会影响网页post请求
有没有一种方法就是
把这个taco.getInredient里面的东西变成Ingredient对象,让这个循环不报错?
!重点就是怎么把这个遍历的列表里json串化的对象变成这个对象,哥儿们
引入 fastjson
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
json 字符串转对象代码如下。
Ingredient ingredient = JSONObject.parseObject(str,Ingredient.class);