package com.kuyuntech.vrv.platform.readJson;

import com.alibaba.fastjson.JSONObject;
import com.kuyuntech.vrv.platform.util.core.FileUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class readDeviceParams {
    public static void main(String[] args) throws IOException {
        String dataFromJsonFile = FileUtils.getDataFromJsonFile("C:\\Users\\askin\\IdeaProjects\\airconditioner\\sources\\server\\vrv\\vrv-platform\\src\\main\\resources\\static\\device-params.json");
//        System.out.println(dataFromJsonFile);

        JSONObject jsonObject = JSONObject.parseObject(dataFromJsonFile);

        String devices = jsonObject.getString("devices");
//        System.out.println(devices);


//取里面的state
        List<Test> list = JSONObject.parseArray(devices, Test.class);
        String deviceId = list.get(0).getDeviceId();
        int deviceState = list.get(0).getDeviceState();
        HashMap<String, String> deviceData = list.get(0).getDeviceData();
        System.out.println(deviceData);

        System.out.println(deviceId + "::" + deviceState);

        for (Map.Entry<String, String> entry : deviceData.entrySet()) {
            String name = entry.getKey();
            String value = entry.getValue();

            System.out.println(name + "------" + value);
        }


    }
}
