Text シリアライザ

TextSerializers provide a convenient way to serialize and de-serialize Text instances. There are three applicable formats:

The TextSerializers class provides three TextSerializers for serializing to a representative String or deserializing to a Text instance:

  • LEGACY_FORMATTING_CODE

  • FORMATTING_CODE

  • JSON

Serializing Text

To serialize a Text object, simply use the TextSerializer#serialize(Text) method, specifying the appropriate Text object as the only argument. The method will return a String representing the Text object.

Deserializing to Text

To deserialize a String into its corresponding Text object, simply use the TextSerializer#deserialize(String) method, specifying the input String as the only argument. If the input is incorrectly formatted, a TextParseException will be thrown. Alternatively, use the TextSerializer#deserializeUnchecked(String) method to deserialize without any exceptions. If there is an error, the raw input will be returned in the form of a Text object.