Kotlin JSON Forms
Customizable JSON Schema-based forms for Kotlin and Compose
This project aims to reimplement JSON Forms in Kotlin for use in Compose-based applications. Rather than defining its own formats or standards, this repo adopts JSON for form configuration and layout of well-known or standardized formats. Form fields and validation is provided in JSON Schema format, and the way the form is laid out and displayed is through JSON Forms format format. Using JSON as as the form definition gives an easy, portable way to display and dynamically change forms in your application.
This repo aims to support all features of the original JSON Forms library, which is written in Javascript, as well as following similar architectural patterns. For all topic related to the JSON format itself, that library's documentation will be a valid reference for this library.
See the video below for an example form in action:
Untitled.mov
Supported Platforms/Features
Currently, JSON Schema validation is provided by the JVM-only json-kotlin-schema, so is only available for JVM-compatible targets. In following the architecture of the original JSON Forms library, the core functionality is not tied to any particular UI framework, and displaying forms in Compose is an extension on top of the core library.
Kotlin JSON Forms is currently available for Compose on Android and Desktop platforms. Adding support for Compose Web is planned.
Installation
repositories {
mavenCentral()
}
// for plain JVM or Android projects
dependencies {
implementation("io.github.copper-leaf:json-forms-core:{{site.version}}")
implementation("io.github.copper-leaf:json-forms-compose:{{site.version}}")
}
// for multiplatform projects
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.copper-leaf:json-forms-core:{{site.version}}")
implementation("io.github.copper-leaf:json-forms-compose:{{site.version}}")
}
}
}
}
Documentation
See the website for detailed documentation and usage instructions.
License
Kotlin JSON Forms is licensed under the BSD 3-Clause License, see LICENSE.md.
References and Dependencies
This project depends on the following libraries:
- json-kotlin-schema for providing JSON parsing and validation on JVM, which itself depends on many other Java or Kotlin JSON libraries by the same author
- Ballast for state management
- richtext-compose-multiplatform for rich text editor capabilities
- compose-code-editor for code editor capabilities