类 JsonUtils

java.lang.Object
com.infilake.openapi.bidding.parser.JsonUtils

public class JsonUtils extends Object
JSON utility class using Jackson for robust JSON processing Provides methods to convert JSON to typed Java objects using Jackson ObjectMapper. Supports nested objects, generic types, and comprehensive error handling.
  • 构造器详细资料

    • JsonUtils

      public JsonUtils()
  • 方法详细资料

    • getObjectMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Get the shared ObjectMapper instance
    • parseToApiResult

      public static <T> ApiResult<T> parseToApiResult(String json, Class<T> dataClass)
      Parse JSON string to ApiResult with single data type
      类型参数:
      T - Type of data
      参数:
      json - JSON string
      dataClass - Class of data object
      返回:
      ApiResult containing the data
    • parseToApiResultList

      public static <T> ApiResult<List<T>> parseToApiResultList(String json, Class<T> itemClass)
      Parse JSON string to ApiResult with List data type
      类型参数:
      T - Type of items
      参数:
      json - JSON string
      itemClass - Class of items in the list
      返回:
      ApiResult containing List of items
    • parseToPageResult

      public static <T> ApiResult<PageResult<T>> parseToPageResult(String json, Class<T> recordClass)
      Parse JSON string to ApiResult with PageResult
      类型参数:
      T - Type of records
      参数:
      json - JSON string
      recordClass - Class of records in the page
      返回:
      ApiResult containing PageResult
    • toJsonString

      public static String toJsonString(Object obj)
      Convert Java object to JSON string
      参数:
      obj - The object to convert
      返回:
      JSON string representation