![](https://bcentral-packageicons.azureedge.net/images/ballerina_toml_0.5.0.png)
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![](/images/permalink.svg)
readFile![](/images/permalink.svg)
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![](/images/permalink.svg)
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![](/images/permalink.svg)
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![](/images/permalink.svg)
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![](/images/permalink.svg)
toml: ReadConfig![](/images/permalink.svg)
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![](/images/permalink.svg)
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![](/images/permalink.svg)
toml: Error![](/images/permalink.svg)
Represents the generic error type for the TOML package.
Simple name reference types![](/images/permalink.svg)
toml: ParsingError![](/images/permalink.svg)
ParsingError
Represents an error caused during the parsing.
toml: WritingError![](/images/permalink.svg)
WritingError
Represents an error caused when writing a TOML file.
toml: LexicalError![](/images/permalink.svg)
LexicalError
Represents an error caused by the lexical analyzer.
toml: GrammarError![](/images/permalink.svg)
GrammarError
Represents an error caused for an invalid grammar production.
toml: ConversionError![](/images/permalink.svg)
ConversionError
Represents an error caused by the Ballerina lang when converting a data type.
Import
import ballerina/toml;
Metadata
Released date: 10 months ago
Version: 0.5.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.8.0
GraalVM compatible: Yes
Pull count
Total: 285
Current verison: 3
Weekly downloads
Keywords
toml
Contributors