package com.ruoyi.dj.mqtt.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.dj.mqtt.common.CommonResponse;
import lombok.extern.slf4j.Slf4j;

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

/**
 * @auther 周志雄
 * @date 2024/7/22 10:08
 */
@Slf4j
public class ParseMethodUtil {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public static CommonResponse parseMethod(String json) {
        try {
            CommonResponse response = objectMapper.readValue(json, CommonResponse.class);
            return response;
        } catch (Exception e) {
            log.error("Failed to parse JSON", e);
            return null;
        }
    }
}
