package com.lutao.cloud.collect.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

/**
 * json工具
 *
 * @author yx
 * @date 2023/07/18
 */
@Slf4j
public class JsonUtilConvert {


    /**
     * 将json转换成数组
     *
     * @param jsonString json字符串
     * @return {@link JsonNode}
     */
    public static JsonNode convertJsonToArray(String jsonString){

        JsonNode jsonArray = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();

            jsonArray = objectMapper.readTree(jsonString);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }

        return jsonArray;
    }

}
