Package-level declarations

Types

Link copied to clipboard
interface JsonSerializer<T> : Json.Serializer<T>

Wrapping interface around com.badlogic.gdx.utils.Json.Serializer. Improves typing by adding nullability information and changes default parameter names.

Link copied to clipboard

Wrapping interface around com.badlogic.gdx.utils.Json.Serializer. Provides null-safety and convenient interface for serializer that is only able to read. Unlike libGDX com.badlogic.gdx.utils.Json.ReadOnlySerializer, the default implementation of the write method throws UnsupportedOperationException.

Functions

Link copied to clipboard
inline fun <T> Json.addClassTag(tag: String)

Sets a tag to use instead of the fully qualifier class name for type T. This can make the JSON easier to read.

Link copied to clipboard
inline fun <T> Json.fromJson(file: FileHandle): T

Parse an object of type T from a file.

inline fun <T> Json.fromJson(string: String): T

Parse an object of type T from a string.

Link copied to clipboard
inline fun <T> Json.getTag(): String?

Returns the tag for type T, or null if none was defined.

Link copied to clipboard
inline fun <T : Iterable<E>, E> Json.readArrayValue(jsonData: JsonValue, name: String? = null): T

Read an iterable value of type T with elements of type E from a jsonData attribute with a name. If name is null, this will directly read jsonData as an iterable of type T.

Link copied to clipboard
inline fun <T> readOnlySerializer(crossinline read: (JsonValue) -> T): Json.Serializer<T>

Factory function to create a simplified ReadOnlyJsonSerializer, which accepts only JsonValue.

inline fun <T> readOnlySerializer(crossinline reader: (Json, JsonValue, Class<*>?) -> T): Json.Serializer<T>

Factory function to create a ReadOnlyJsonSerializer from lambda.

Link copied to clipboard
inline fun <T> Json.readValue(jsonData: JsonValue, name: String? = null): T

Read a value of type T from a jsonData attribute with a name. If name is null, this will directly read jsonData as an object of type T.

Link copied to clipboard
inline fun <T, E> Json.setElementType(fieldName: String)

Sets the elements in a collection of type T to type E. When the element type is known, the class for each element in the collection does not need to be written unless different from the element type.

Link copied to clipboard
inline fun <T> Json.setSerializer(serializer: Json.Serializer<T>)

Registers a serializer to use for type T instead of the default behavior of serializing all of an object fields.