beginFlatten

fun beginFlatten(): Int

Cancels immediately-nested calls to beginArray or beginObject and theirmatching calls to endArray or endObject. Use this to compose JSON adapterswithout nesting.

For example, the following creates JSON with nested arrays: {@code [1,[2,3,4],5]}.

{@code * JsonAdapter

With flattening we can create JSON with a single array {@code [1,2,3,4,5]}:

{@code * JsonAdapter

This method flattens arrays within arrays:

{@code * Emit: [1, [2, 3, 4], 5] * To produce: [1, 2, 3, 4, 5] * }
It also flattens objects within objects. Do not call name before writing a flattenedobject.
{@code * Emit: {"a": 1, {"b": 2}, "c": 3} * To Produce: {"a": 1, "b": 2, "c": 3} * }
Other combinations are permitted but do not perform flattening. For example, objects inside ofarrays are not flattened:
{@code * Emit: [1, {"b": 2}, 3, [4, 5], 6] * To Produce: [1, {"b": 2}, 3, 4, 5, 6] * }

This method returns an opaque token. Callers must match all calls to this method with a callto endFlatten with the matching token.