# Class DocumentIndexSerializer

java.lang.Object
com.codename1.documents.DocumentIndexSerializer

public final class DocumentIndexSerializer extends Object

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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `VERSION`
  The schema version written into every index.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DocumentNode`
  `deserialize(String json)`
  Parses an index produced by `serialize`.
  `static String`
  `serialize(DocumentNode root)`
  Serializes a document tree.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### VERSION

    public static final int VERSION
    The schema version written into every index.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### serialize

    public static String serialize(DocumentNode root)

    Serializes a document tree.

    ###### Parameters

    - `root`: 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`: the index JSON

    ###### Returns

    the root node

    ###### Throws

    - `IOException`: when the text is not readable as an index
    Throws:
      `IOException`