Class ValueDecoder
java.lang.Object
dev.toonformat.jtoon.decoder.ValueDecoder
Main decoder for converting TOON-formatted strings to Java objects.
Implements a line-by-line parser with indentation-based depth tracking.
Delegates primitive type inference to PrimitiveDecoder.
Parsing Strategy:
- Split input into lines
- Track current line position and indentation depth
- Use regex patterns to detect structure (arrays, objects, primitives)
- Recursively process nested structures
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Objectdecode(String toon, DecodeOptions options) Decodes a TOON-formatted string to a Java object.static StringdecodeToJson(String toon, DecodeOptions options) Decodes a TOON-formatted string directly to a JSON string using custom options.
-
Method Details
-
decode
Decodes a TOON-formatted string to a Java object.- Parameters:
toon- TOON-formatted input stringoptions- parsing options (delimiter, indentation, 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 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
-