package com.youchain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;

public class testMain {
    @Test
    public static void main(String[] args) {
        String resultJson="{\n" +
                "    \"data\": [\n" +
                "        {\n" +
                "            \"containerCode\": \"qht1188\",\n" +
                "            \"nodeCode\": \"MA1151-HBM02\",\n" +
                "            \"orientation\": \"-179.87\",\n" +
                "            \"containerModelCode\": \"JINGZHOU_qht_160\",\n" +
                "            \"emptyFullStatus\": 0,\n" +
                "            \"inMapStatus\": 0,\n" +
                "            \"isCarry\": 0,\n" +
                "            \"containerCheckCode\": \"qht1188\"\n" +
                "        }\n" +
                "    ],\n" +
                "    \"code\": \"0\",\n" +
                "    \"message\": null,\n" +
                "    \"success\": true\n" +
                "}";
        JSONObject resulObject = JSON.parseObject(resultJson);
        String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
        if(code.equals("0")){
            String data=resulObject.getString("data") == null ? "" : resulObject.getString("data");
            JSONArray jsonArray=JSON.parseArray(data);
            JSONObject dataObject=JSON.parseObject(jsonArray.get(0).toString());
            String isCarry=dataObject.getString("isCarry") == null ? "" : dataObject.getString("isCarry");
            System.out.println(isCarry);
        }
    }
}
