ballerina/toml Ballerina library
Overview
This module provides APIs to convert a TOML configuration file to map<json>
, and vice-versa.
Since the parser is following LL(1) grammar, it follows a non-recursive predictive parsing algorithm which operates in a linear time complexity.
For information on the operations, which you can perform with the toml
module, see the below Functions.
Functions
readFile
function readFile(string filePath, *ReadConfig config) returns map<json>|Error
Parses a TOML file into a Ballerina map object.
Parameters
- filePath string - Path to the toml file
- config *ReadConfig - Configuration for reading a TOML file
readString
function readString(string tomlString, *ReadConfig config) returns map<json>|Error
Parses a Ballerina string of TOML content into a Ballerina map object.
Parameters
- tomlString string - TOML content
- config *ReadConfig - Configuration for reading a TOML file
writeFile
function writeFile(string filePath, map<json> tomlStructure, *WriteConfig config) returns Error?
Writes the TOML structure to a file.
Parameters
- filePath string - Path to the file
- tomlStructure map<json> - Structure to be written to the file
- config *WriteConfig - Configurations for writing a TOML file
Return Type
- Error? - An error on failure
writeString
function writeString(map<json> tomlStructure, *WriteConfig config) returns string[]|Error
Converts the TOML structure to an array of strings.
Parameters
- tomlStructure map<json> - Structure to be written to the file
- config *WriteConfig - Configurations for writing a TOML file
Records
toml: ReadConfig
Configurations for reading a TOML document.
Fields
- parseOffsetDateTime boolean(default true) - If set, then offset date time is converted to Ballerina time:Utc
toml: WriteConfig
Configurations for writing a TOML document.
Fields
- indentationPolicy int(default 2) - Number of spaces for an indentation
- allowDottedKeys boolean(default true) - If set, dotted keys are used instead of standard tables where applicable.
Errors
toml: Error
Represents the generic error type for the TOML package.
Simple name reference types
toml: ParsingError
ParsingError
Represents an error caused during the parsing.
toml: WritingError
WritingError
Represents an error caused when writing a TOML file.
toml: LexicalError
LexicalError
Represents an error caused by the lexical analyzer.
toml: GrammarError
GrammarError
Represents an error caused for an invalid grammar production.
toml: ConversionError
ConversionError
Represents an error caused by the Ballerina lang when converting a data type.
Import
import ballerina/toml;
Metadata
Released date: 8 months ago
Version: 0.5.1
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.8.0
GraalVM compatible: Yes
Pull count
Total: 368
Current verison: 280
Weekly downloads
Keywords
toml
Contributors