Json,Object互相转换

import com.alibaba.fastjson.JSONObject;

Object,List<Object>转JsonStr
String jsonString = JSONObject.toJSONString(object);

JsonStr转JSONObject
JSONObject jSONObject = JSONObject.parseObject(jsonStr);

JsonStr转Object
BeanName beanName = JSONObject.parseObject(beanJsonStr, BeanName.class);

JsonStr转List<Object>
List<BeanName> parseArray = JSONObject.parseArray(beanJsonStr, BeanName.class);

posted @ 2021-08-23 18:14  WishYouWell  阅读(496)  评论(0)    收藏  举报