kaml alternatives and similar libraries
Based on the "Misc" category.
Alternatively, view kaml alternatives based on common mentions on social networks and blogs.
-
jclasslib
jclasslib bytecode viewer is a tool that visualizes all aspects of compiled Java class files and the contained bytecode. -
kotlin-logging
Lightweight logging framework for Kotlin. Used as a wrapper for slf4j with Kotlin extensions. -
klock
Consistent and portable date and time utilities for multiplatform kotlin (JVM, JS and Common). -
Humanizer.jvm
Humanizer.jvm meets all your jvm needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities. -
actions-on-google-kotlin
Port of official Node.js SDK to Kotlin. Complete with all features and tests and nearly identical API. -
klutter
A mix of random small libraries for Kotlin, the smallest reside here until big enough for their own repository. -
SimpleDNN
SimpleDNN is a machine learning lightweight open-source library part of KotlinNLP and has been designed to support relevant neural network architectures in natural language processing tasks. -
kassava
This library provides some useful kotlin extension functions for implementing toString() and equals() without all of the boilerplate. -
kotlin-futures
A collections of extension functions to make the JVM Future, CompletableFuture, ListenableFuture API more functional and Kotlin like. -
PrimeCalendar
Provides all of the java.util.Calendar functionalities for Civil, Persian, Hijri, Japanese, etc, as well as their conversion to each other. -
kasechange
Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case
Get performance insights in less than 4 minutes
* 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?
README
kaml
What is this?
This library adds YAML support to kotlinx.serialization.
YAML version 1.2 is supported.
Usage samples
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.decodeFromString(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.encodeToString(Team.serializer(), input)
println(result)
Referencing kaml
Add the following to your Gradle build script:
Groovy DSL
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.20'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.20'
}
dependencies {
implementation "com.charleskorn.kaml:kaml:<version number here>" // Get the latest version number from https://github.com/charleskorn/kaml/releases/latest
}
Kotlin DSL
plugins {
kotlin("jvm") version "1.4.20"
kotlin("plugin.serialization") version "1.4.20"
}
dependencies {
implementation("com.charleskorn.kaml:kaml:<version number here>") // Get the latest version number from https://github.com/charleskorn/kaml/releases/latest
}
Check the releases page for the latest release information, and the Maven Central page for examples of how to reference the library in other build systems.
Features
Supports most major YAML features:
- Scalars, including strings, booleans, integers and floats
- Sequences (lists)
- Maps
- Nulls
- Aliases and anchors, including merging aliases to form one map
Supports parsing YAML to Kotlin objects (deserializing) and writing Kotlin objects as YAML (serializing)
Supports kotlinx.serialization's polymorphism for sealed and unsealed types
Two styles are available (set YamlConfiguration.polymorphismStyle
when creating an instance of Yaml
):
using YAML tags to specify the type:
servers: - !<frontend> hostname: a.mycompany.com - !<backend> database: db-1
using a
type
property to specify the type:servers: - type: frontend hostname: a.mycompany.com - type: backend database: db-1
The fragments above could be generated with:
@Serializable
sealed class Server {
@SerialName("frontend")
@Serializable
data class Frontend(val hostname: String)
@SerialName("backend")
@Serializable
data class Backend(val database: String)
}
@Serializable
data class Config(val servers: List<Server>)
val config = Config(listOf(
Frontend("a.mycompany.com"),
Backend("db-1")
))
val result = Yaml.default.encodeToString(Config.serializer(), config)
println(result)
x-common-labels: &common-labels
labels:
owned-by: [email protected]
cost-centre: myteam
servers:
server-a:
<<: *common-labels
kind: frontend
server-b:
<<: *common-labels
kind: backend
# server-b and server-c are equivalent
server-c:
labels:
owned-by: [email protected]
cost-centre: myteam
kind: backend
Specify the extension prefix by setting YamlConfiguration.extensionDefinitionPrefix
when creating an instance of Yaml
(eg. "x-"
for the example above).
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.
Contributing to kaml
Pull requests and bug reports are always welcome!
kaml uses Batect to simplify development environment setup:
- To build the library:
./batect build
- To run the tests and static analysis tools:
./batect check
- To run the tests and static analysis tools continuously:
./batect continuousCheck
Other commands are available by running ./batect --list-tasks
Reference links
- YAML 1.2 Specification
- snakeyaml-engine, the YAML parser this library is based on
*Note that all licence references and agreements mentioned in the kaml README section above
are relevant to that project's source code only.