JsonIntegration

abstract class JsonIntegration<F, A>

Integrates a JSON library like Moshi or Gson into proto. This rigid interface attempts to make it easy all JSON libraries to encode and decode JSON in the exact same way.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract fun formatterAdapter(jsonStringAdapter: JsonFormatter<*>): A

Returns an adapter that applies jsonStringAdapter to each value.

Link copied to clipboard
abstract fun frameworkAdapter(framework: F, type: Type): A

Returns framework's built-in adapter for type.

Link copied to clipboard
fun <M : Any, B : Any> jsonAdapters(adapter: RuntimeMessageAdapter<M, B>, framework: F): List<A>

Returns a message type that supports encoding and decoding JSON objects of type type.

Link copied to clipboard
abstract fun listAdapter(elementAdapter: A): A

Returns an adapter iterates a list of the target adapter.

Link copied to clipboard
abstract fun mapAdapter(framework: F, keyFormatter: JsonFormatter<*>, valueAdapter: A): A

Returns an adapter iterates keys and values of the target adapter.

Link copied to clipboard
abstract fun structAdapter(framework: F): A

Returns an adapter that handles trees of Maps, Lists, and other JSON types. Should always serialize nulls, including when they are values in maps.