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.
Use¶
The JSON serializer works similar to all others, providing the basic serialize and deserialize operations:
// Component to text
final String jsonText = JSONComponentSerializer.json().serialize(Component.text("Hello world", NamedTextColour.LIGHT_PURPLE));
// JSON string to component
final Component comp = JSONComponentSerializer.json().deserialize(jsonText);
Additionally, there is a JSONComponentSerializer.builder()
available for advanced use that requires configuring legacy compatibility options.
Known Implementations¶
Name |
Description |
---|---|
A mature serializer working with Google’s Gson library. |