Parser
An object responsible for parsing JSON data from various sources into a TimelineData object.
This parser uses Moshi for JSON deserialization and provides both traditional exception-based and modern Result-based APIs for error handling. The parser is stateless and thread-safe.
Example usage:
// Exception-based API (backward compatible)
val data = Parser.parse(file)
// Result-based API (recommended)
when (val result = Parser.parseToResult(file)) {
is ParseResult.Success -> println("Parsed ${result.data.semanticSegments.size} segments")
is ParseResult.Error -> println("Error: ${result.message}")
}
// With custom configuration
val data = Parser.parse(file, ParserConfig.PERFORMANCE)
Functions
Creates a parser result from a file path string.
Creates a parser result from a JSON string.
Parses the given file into a TimelineData object using default configuration.
Parses the given input stream into a TimelineData object using default configuration.
Parses the given buffered source into a TimelineData object using default configuration.
Parses the given file into a TimelineData object with custom configuration.
Parses the given input stream into a TimelineData object with custom configuration.
Parses the given buffered source into a TimelineData object with custom configuration.
Parses the given file into a ParseResult using default configuration.
Parses the given input stream into a ParseResult using default configuration.
Parses the given buffered source into a ParseResult using default configuration.
Parses the given file into a ParseResult with custom configuration.
Parses the given input stream into a ParseResult with custom configuration.
Parses the given buffered source into a ParseResult with custom configuration.