-
public class JsonUtility object for converting Kotlin objects to JSON representations.
-
-
Method Summary
Modifier and Type Method Description final ObjecttoJSONPrimitive(Object value)Converts any Kotlin object to a JSON-compatible primitive or complex type. final ObjecttoJsonPrimitive(Object $self)Extension function for Any? final <T extends Any> JSONObjecttoJSONObject(T data)Converts any Kotlin object to a JSONObject. final <T extends Collection<Any>> JSONArraytoJSONArray(T data)Converts a Collection to a JSONArray. -
-
Method Detail
-
toJSONPrimitive
final Object toJSONPrimitive(Object value)
Converts any Kotlin object to a JSON-compatible primitive or complex type.
Handles various primitive types, collections, maps, and custom objects. Special handling is provided for Rust-derived sealed classes.
- Parameters:
value- The value to convert to a JSON-compatible form
-
toJsonPrimitive
final Object toJsonPrimitive(Object $self)
Extension function for Any? to convert to a JSON primitive.
-
toJSONObject
final <T extends Any> JSONObject toJSONObject(T data)
Converts any Kotlin object to a JSONObject.
Uses reflection to get all properties of the object and converts each to a JSON-compatible form.
- Parameters:
data- The object to convert
-
toJSONArray
final <T extends Collection<Any>> JSONArray toJSONArray(T data)
Converts a Collection to a JSONArray.
Each element in the collection is converted to a JSON-compatible form.
- Parameters:
data- The collection to convert
-
-
-
-