package com.usky.rule.util;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.usky.rule.exception.BizException;
import java.io.IOException;

public class JsonToStringDeserializer extends JsonDeserializer<String> {
    public JsonToStringDeserializer() {
    }

    public String deserialize(JsonParser jp, DeserializationContext context) throws IOException {
        ObjectMapper mapper = (ObjectMapper)jp.getCodec();
        JsonNode node = (JsonNode)mapper.readTree(jp);

        try {
            return mapper.writeValueAsString(node);
        } catch (JsonProcessingException var6) {
            throw new BizException("格式有误");
        }
    }
}
