JSON.parseObject的⼏种⽤法
import com.alibaba.fastjson.JSONObject;
⼀.result格式:
{
"success":"true";
"returnAddress":"123"
}
JSONObject jsonObject=JSON.parseObject(result); //转换成object
⼆.result格式:
{
"success":"true";
"data":{
"shop_uid":"123";
};
}
JSONObject shop_user =JSON.parseObject(result);
JSON.parseObject(shop_user .getString("data")).getString("shop_uid")
三.result格式:
{
"success":"true";
"data":[{
fastjson字符串转数组
"shop_uid":"123";
},
{
"shop_name":"张三"
}]
}
1. payload:{
2. t: [{
3. id: 3004463, creator: "luojian", gmtCreated: 1584683688000, modifier: "luojian",…
4. }],
5. count: 2}
/
**把⼤的字符串转为json对象*/
JSONObject payload = JSONObject.ResultString()).getJSONObject("payload");
String count = String("count");
if(Integer.parseInt(count) > 0){
return JSONObject.String("t"),FullDiscountQueryDTO.class);//Json字符串数据转换成集合对象JSONArray detail = JSON.parseArray(result);
for (int i=0; i<detail.size();i++){
(i)!=null||!(i).equals("")){
JSONArray detailChild =JSONArray(i);
Integer(1)>Integer.("shiptime").toString())){ ship.put("shiptime",Integer(1));
ship.put("desc",String(0));
}
}
}
JSON转javaBean
1.1 JSONobject=>javaBean
JSONObject contentChild = JSONObject(i); QCCustomerScore.CustomerCore customerCore = JSON
.toJavaObject(contentChild, QCCustomerScore.CustomerCore.class);
1.2 String转javaBean
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论