kaml alternatives and similar libraries
Based on the "Misc" category
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of kaml or a related project?
What is this?
This library adds YAML support to kotlinx.serialization.
YAML version 1.2 is supported.
Parsing from YAML to a Kotlin object
@Serializable data class Team( val leader: String, val members: List<String> ) val input = """ leader: Amy members: - Bob - Cindy - Dan """.trimIndent() val result = Yaml.default.parse(Team.serializer(), input) println(result)
Serializing from a Kotlin object to YAML
@Serializable data class Team( val leader: String, val members: List<String> ) val input = Team("Amy", listOf("Bob", "Cindy", "Dan")) val result = Yaml.default.stringify(Team.serializer(), input) println(result)
Supported YAML features
- Scalars, including strings, booleans, integers and floats
- Sequences (lists)
- Aliases and anchors
- Merging aliases to form one map
- Docker Compose-style extension fields
Specify the extension prefix by setting
extensionDefinitionPrefix when creating an instance of
Extensions can only be defined at the top level of a document, and only if the top level element is a map or object. Any key starting with the extension prefix must have an anchor defined and will not be included in the deserialised value.
Add the following to your Gradle build script:
implementation("com.charleskorn.kaml:kaml:<version number here>")
Contributing to kaml
Pull requests and bug reports are always welcome!
kaml uses batect to simplify development environment setup:
- To build the library:
- To run the tests and static analysis tools:
- To run the tests and static analysis tools continuously:
Other commands are available by running
*Note that all licence references and agreements mentioned in the kaml README section above are relevant to that project's source code only.