JSON
The JSON serializer provides a common interface for serializer implementations that translate between a Component and JSON strings. This allows a library to support any underlying JSON library than an application may want to use.
The JSON serializer works similar to all others, providing the basic serialize and deserialize operations:
// Component to textfinal String jsonText = JSONComponentSerializer.json().serialize(Component.text("Hello world", NamedTextColor.LIGHT_PURPLE));
// JSON string to componentfinal Component comp = JSONComponentSerializer.json().deserialize(jsonText);
Additionally, there is a JSONComponentSerializer.builder()
available for advanced use that requires configuring legacy compatibility options.
Known Implementations
Section titled “Known Implementations”Name | Description |
---|---|
adventure-text-serializer-gson | A mature serializer working with Google’s Gson library. |