JsonConfig is a lightweight Java library for reading and editing JSON configuration files.
Most JSON libraries (like Gson or Jackson) force you to map your JSON data directly to Java objects. This works well for APIs, but it makes handling dynamic configuration files difficult. JsonConfig works differently: it treats JSON like a file system. You can read, write, and modify values using simple paths like server.database.port or users[0].name, without creating a single new class.
- Zero Dependencies: The core module contains its own strict JSON parser. You don't need to shade or bundle any other libraries.
- Path Access: Access deeply nested values using dot notation. Arrays are supported using standard bracket syntax (
[index]). - Thread Safety: If you need to access configs from multiple threads, use the provided
ConcurrentJsonConfiguration. It uses ReadWriteLocks to ensure safe reads and writes. - Config Merging: Easily update user configurations by merging them with bundled defaults. Strategies include:
OVERWRITE: Replace values completely.DEEP_MERGE_OBJECTS: Recurses into objects to merge new keys whilst preserving existing ones.CONCAT_ARRAYS: Appends new array elements to existing lists.
- Strict Compliance: The parser adheres strictly to the JSON standard, ensuring files are always valid JSON.
- Optional Integrations: If you already use Gson or Jackson in your project, optional modules allow seamless conversion between their types and JsonConfig types.
This library is available via JitPack.
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.frosxt:JsonConfig:v1.0.1'
}repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
dependencies {
implementation("com.github.frosxt:JsonConfig:v1.0.1")
}<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.frosxt</groupId>
<artifactId>JsonConfig</artifactId>
<version>v1.0.1</version>
</dependency>If you only want specific modules (e.g., just the core library vs the full repo):
Gradle:
implementation("com.github.frosxt.JsonConfig:jsonconfig-core:v1.0.1")
implementation("com.github.frosxt.JsonConfig:jsonconfig-gson:v1.0.1")Maven:
<dependency>
<groupId>com.github.frosxt.JsonConfig</groupId>
<artifactId>jsonconfig-core</artifactId>
<version>v1.0.1</version>
</dependency>jsonconfig-core: Main library (Parser, Path Logic, API).jsonconfig-gson: Adapters for Google Gson.jsonconfig-jackson: Adapters for Jackson Databind.
- Java 21 or newer
- Gradle or Maven
Documentation is available on the Wiki
MIT License. See LICENSE.