Class JsonUtils
java.lang.Object
org.springframework.ai.vectorsore.JsonUtils
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionConverts a JSON string to a map.Converts a list of floats to a list of doubles.static float[]
toFloatArray
(List<Double> embeddingDouble) Converts a list of doubles to a float array.toFloatList
(List<Double> embeddingDouble) Converts a list of doubles to a list of floats.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
jsonToMap
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
Converts a list of doubles to a list of floats.- Parameters:
embeddingDouble
- the list of doubles to convert- Returns:
- the list of floats
-
toFloatArray
Converts a list of doubles to a float array.- Parameters:
embeddingDouble
- the list of doubles to convert- Returns:
- the float array
-
toDouble
Converts a list of floats to a list of doubles.- Parameters:
floats
- the list of floats to convert- Returns:
- the list of doubles
-