类 JacksonHelper

java.lang.Object
com.github.codeboyzhou.mcp.declarative.util.JacksonHelper

public final class JacksonHelper extends Object
Helper class for Jackson JSON and YAML serialization and deserialization.

This class provides static methods for serializing and deserializing objects to and from JSON and YAML formats using Jackson.

作者:
codeboyzhou
  • 方法详细资料

    • toJsonString

      public static String toJsonString(Object object)
      Serialize an object to a JSON string.
      参数:
      object - the object to serialize
      返回:
      the JSON string representation of the object
    • fromJson

      public static <T> T fromJson(String json, Class<T> valueType)
      Deserialize a JSON string to an object of the specified type.
      类型参数:
      T - the type of the object to deserialize to
      参数:
      json - the JSON string to deserialize
      valueType - the class of the object to deserialize to
      返回:
      the deserialized object
    • fromYaml

      public static <T> T fromYaml(File yamlFile, Class<T> valueType)
      Deserialize a YAML file to an object of the specified type.
      类型参数:
      T - the type of the object to deserialize to
      参数:
      yamlFile - the YAML file to deserialize
      valueType - the class of the object to deserialize to
      返回:
      the deserialized object