Class JsonUtils

java.lang.Object
org.springframework.ai.vectorsore.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
    • toFloatList

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

      public static float[] toFloatArray(List<Double> embeddingDouble)
      Converts a list of doubles to a float array.
      Parameters:
      embeddingDouble - 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