public final class DocumentIndexSerializer

  1. Object
  2. DocumentIndexSerializer

Converts a published document tree to and from the index.json the platform readers consume.

The format is deliberately small and forward-compatible: absent keys mean “unknown”, which is what lets a reader written against one version of the schema survive a newer publisher. v carries the schema version so a future reader can tell a missing key from a renamed one.

The reader half exists for the simulator and for tests. On device the parsing is done natively – Swift in the Apple extension, Java in the Android provider – because the app process is not running when the browser asks.

Fields

public static final int VERSION = 1The schema version written into every index.

Methods

public static String serialize(DocumentNode root)Serializes a document tree.
public static DocumentNode deserialize(String json) throws IOExceptionParses an index produced by serialize.

Inherited methods

Field details

VERSION

public static final int VERSION = 1
The schema version written into every index.

Method details

serialize

public static String serialize(DocumentNode root)
Serializes a document tree.

Parameters

root DocumentNode
the root node, must not be null

Returns

the index JSON

deserialize

public static DocumentNode deserialize(String json) throws IOException
Parses an index produced by serialize.

Parameters

json String
the index JSON

Returns

the root node

Throws

IOException
when the text is not readable as an index