Class JToon
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectDecodes a TOON-formatted string to Java objects using default options.static Objectdecode(String toon, DecodeOptions options) Decodes a TOON-formatted string to Java objects using custom options.static StringdecodeToJson(String toon) Decodes a TOON-formatted string directly to a JSON string using default options.static StringdecodeToJson(String toon, DecodeOptions options) Decodes a TOON-formatted string directly to a JSON string using custom options.static StringEncodes a Java object to JToon format using default options.static Stringencode(Object input, EncodeOptions options) Encodes a Java object to JToon format using custom options.static StringencodeJson(String json) Encodes a plain JSON string to TOON format using default options.static StringencodeJson(String json, EncodeOptions options) Encodes a plain JSON string to TOON format using custom options.
-
Method Details
-
encode
Encodes a Java object to JToon format using default options.The object is first normalized (Java types are converted to JSON-compatible representations), then encoded to JToon format.
- Parameters:
input- The object to encode (can be null)- Returns:
- The JToon-formatted string
-
encode
Encodes a Java object to JToon format using custom options.The object is first normalized (Java types are converted to JSON-compatible representations), then encoded to JToon format.
- Parameters:
input- The object to encode (can be null)options- Encoding options (indent, delimiter, length marker)- Returns:
- The JToon-formatted string
-
encodeJson
Encodes a plain JSON string to TOON format using default options.This is a convenience overload that parses the JSON string and encodes it without requiring callers to create a
JsonNodeor intermediate objects.- Parameters:
json- The JSON string to encode (must be valid JSON)- Returns:
- The TOON-formatted string
- Throws:
IllegalArgumentException- if the input is not valid JSON
-
encodeJson
Encodes a plain JSON string to TOON format using custom options.Parsing is delegated to
JsonNormalizer.parse(String)to maintain separation of concerns.- Parameters:
json- The JSON string to encode (must be valid JSON)options- Encoding options (indent, delimiter, length marker)- Returns:
- The TOON-formatted string
- Throws:
IllegalArgumentException- if the input is not valid JSON
-
decode
Decodes a TOON-formatted string to Java objects using default options.Returns a Map for objects, List for arrays, or primitives (String, Number, Boolean, null) for scalar values.
- Parameters:
toon- The TOON-formatted string to decode- Returns:
- Parsed object (Map, List, primitive, or null)
- Throws:
IllegalArgumentException- if strict mode is enabled and input is invalid
-
decode
Decodes a TOON-formatted string to Java objects using custom options.Returns a Map for objects, List for arrays, or primitives (String, Number, Boolean, null) for scalar values.
- Parameters:
toon- The TOON-formatted string to decodeoptions- Decoding options (indent, delimiter, strict mode)- Returns:
- Parsed object (Map, List, primitive, or null)
- Throws:
IllegalArgumentException- if strict mode is enabled and input is invalid
-
decodeToJson
Decodes a TOON-formatted string directly to a JSON string using default options.This is a convenience method that decodes TOON to Java objects and then serializes them to JSON.
- Parameters:
toon- The TOON-formatted string to decode- Returns:
- JSON string representation
- Throws:
IllegalArgumentException- if strict mode is enabled and input is invalid
-
decodeToJson
Decodes a TOON-formatted string directly to a JSON string using custom options.This is a convenience method that decodes TOON to Java objects and then serializes them to JSON.
- Parameters:
toon- The TOON-formatted string to decodeoptions- Decoding options (indent, delimiter, strict mode)- Returns:
- JSON string representation
- Throws:
IllegalArgumentException- if strict mode is enabled and input is invalid
-