Class JsonUtils

java.lang.Object
org.springframework.ai.vectorstore.JsonUtils

public class JsonUtils extends Object
Utility class for JSON processing. Provides methods for converting JSON strings to maps and lists, and for converting between lists of different numeric types.
Author:
Christian Tzolov
  • Constructor Details

    • JsonUtils

      public JsonUtils()
  • Method Details

    • jsonToMap

      public static Map<String,Object> jsonToMap(String jsonText)
      Converts a JSON string to a map.
      Parameters:
      jsonText - the JSON string to convert
      Returns:
      the map representation of the JSON string
      Throws:
      RuntimeException - if an error occurs during the conversion
    • toFloatArray

      public static float[] toFloatArray(List<Float> embedding)
      Converts a list of doubles to a float array.
      Parameters:
      embedding - the list of doubles to convert
      Returns:
      the float array
    • toDouble

      public static List<Double> toDouble(List<Float> floats)
      Converts a list of floats to a list of doubles.
      Parameters:
      floats - the list of floats to convert
      Returns:
      the list of doubles