Package net.md_5.bungee.chat

# Class ComponentSerializer

java.lang.Object
net.md_5.bungee.chat.ComponentSerializer

All Implemented Interfaces:
  `com.google.gson.JsonDeserializer<BaseComponent>`

public class ComponentSerializer extends Object implements com.google.gson.JsonDeserializer<BaseComponent>

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ComponentSerializer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static BaseComponent`
  `deserialize(com.google.gson.JsonElement jsonElement)`
  Deserialize a JSON element as a single component.
  `BaseComponent`
  `deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context)`
  `static BaseComponent`
  `deserialize(String json)`
  Deserialize a JSON-compliant String as a single component.
  `static ComponentStyle`
  `deserializeStyle(com.google.gson.JsonElement jsonElement)`
  Deserialize a JSON element as a component style.
  `static ComponentStyle`
  `deserializeStyle(String json)`
  Deserialize a JSON-compliant String as a component style.
  `static BaseComponent[]`
  `parse(String json)`
  Parse a JSON-compliant String as an array of base components.
  `static com.google.gson.JsonElement`
  `toJson(BaseComponent component)`
  `static com.google.gson.JsonElement`
  `toJson(ComponentStyle style)`
  `static String`
  `toString(Object object)`
  Deprecated.
  Error-prone, be careful which object you input here
  `static String`
  `toString(BaseComponent component)`
  `static String`
  `toString(BaseComponent... components)`
  `static String`
  `toString(ComponentStyle style)`
  `static String`
  `toString(Content content)`
  Deprecated.
  for legacy internal use only

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### ComponentSerializer

    public ComponentSerializer()

- ## Method Details

  - ### parse

    public static BaseComponent[] parse(String json)
    Parse a JSON-compliant String as an array of base components. The input can be one of either an array of components, or a single component object. If the input is an array, each component will be parsed individually and returned in the order that they were parsed. If the input is a single component object, a single-valued array with the component will be returned.

    NOTE: `deserialize(String)` is preferred as it will parse only one component as opposed to an array of components which is non- standard behavior. This method is still appropriate for parsing multiple components at once, although such use case is rarely (if at all) exhibited in vanilla Minecraft.

    Parameters:
      `json` - the component json to parse
    Returns:
      an array of all parsed components

  - ### deserialize

    public static BaseComponent deserialize(String json)
    Deserialize a JSON-compliant String as a single component.
    Parameters:
      `json` - the component json to parse
    Returns:
      the deserialized component
    Throws:
      `IllegalArgumentException` - if anything other than a valid JSON component string is passed as input

  - ### deserialize

    public static BaseComponent deserialize(com.google.gson.JsonElement jsonElement)
    Deserialize a JSON element as a single component.
    Parameters:
      `jsonElement` - the component json to parse
    Returns:
      the deserialized component
    Throws:
      `IllegalArgumentException` - if anything other than a valid JSON component is passed as input

  - ### deserializeStyle

    public static ComponentStyle deserializeStyle(String json)
    Deserialize a JSON-compliant String as a component style.
    Parameters:
      `json` - the component style json to parse
    Returns:
      the deserialized component style
    Throws:
      `IllegalArgumentException` - if anything other than a valid JSON component style string is passed as input

  - ### deserializeStyle

    public static ComponentStyle deserializeStyle(com.google.gson.JsonElement jsonElement)
    Deserialize a JSON element as a component style.
    Parameters:
      `jsonElement` - the component style json to parse
    Returns:
      the deserialized component style
    Throws:
      `IllegalArgumentException` - if anything other than a valid JSON component style is passed as input

  - ### toJson

    public static com.google.gson.JsonElement toJson(BaseComponent component)

  - ### toJson

    public static com.google.gson.JsonElement toJson(ComponentStyle style)

  - ### toString

    @Deprecated public static String toString(Object object)
    Deprecated.
    Error-prone, be careful which object you input here
    Parameters:
      `object` - the object to serialize
    Returns:
      the JSON string representation of the object

  - ### toString

    @Deprecated public static String toString(Content content)
    Deprecated.
    for legacy internal use only
    Parameters:
      `content` - the content to serialize
    Returns:
      the JSON string representation of the object

  - ### toString

    public static String toString(BaseComponent component)

  - ### toString

    public static String toString(BaseComponent... components)

  - ### toString

    public static String toString(ComponentStyle style)

  - ### deserialize

    public BaseComponent deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
    Specified by:
      `deserialize` in interface `com.google.gson.JsonDeserializer<BaseComponent>`
    Throws:
      `com.google.gson.JsonParseException`