A simple java json configuration system built with gson.

Overview

Simple Configuration

A simple json configuration system built with gson.

Setup 💻

Using Maven

REPOSITORY

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

DEPENDENCY

<dependency>
    <groupId>com.github.DeeKaPPy</groupId>
    <artifactId>simple-configuration</artifactId>
    <version>1.3-SNAPSHOT</version> <!-- or replace with newer version -->
</dependency>

Usage 📚

Initialize

class Bootstrap {

    private final ConfigLoader configLoader;

    public Bootstrap() {

        configLoader = new ConfigLoader(); // you can add you own gson instance

        /*
        loading
         */
        Config config = configLoader.load(Config.class, new Config()); // pass the class and default options

        config.setName("John");

        /*
        save
         */
        configLoader.save(Config.class, config); // pass the class and the config object

        /*
        add custom adapters
         */
        configLoader.addAdapter(NewObject.class, new NewAdapter());
        
        /*
        add any other custom properties to GsonBuilder
         */
        GsonBuilder gsonBuilder = configLoader.getGsonBuilder(); // get the gson builder
        gsonBuilder.registerTypeAdapter(ExampleObject.class, new ExampleAdapter());
        gsonBuilder.excludeFieldsWithoutExposeAnnotation();
        
        configLoader.setGsonBuilder(gsonBuilder); // re set the gson builder
    }

}

Config Class

@ConfigurationFile(
    directory = "./configs/test",
    file = "config.json"
)
class Config {
    private String name;
    @ConfigurationExclusion
    private int age;
}
Comments
  • build(deps): bump maven-shade-plugin from 3.3.0 to 3.4.0

    build(deps): bump maven-shade-plugin from 3.3.0 to 3.4.0

    Bumps maven-shade-plugin from 3.3.0 to 3.4.0.

    Commits
    • 885de67 [maven-release-plugin] prepare release maven-shade-plugin-3.4.0
    • dc8f067 Revert "[maven-release-plugin] prepare release maven-shade-plugin-3.3.1"
    • dcd5cae Revert "[maven-release-plugin] prepare for next development iteration"
    • b2d5b53 [maven-release-plugin] prepare for next development iteration
    • a09e6de [maven-release-plugin] prepare release maven-shade-plugin-3.3.1
    • 875114a [MSHADE-416] Fix Jenkins URL
    • ad2f6f8 [MSHADE-425] Relocate services name before add to serviceEntries
    • 26b5873 gha shared v3
    • 3994b11 Bump xmlunit-legacy from 2.7.0 to 2.9.0
    • 89d9e79 Added release drafter.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • build(deps): bump gson from 2.9.0 to 2.9.1

    build(deps): bump gson from 2.9.0 to 2.9.1

    Bumps gson from 2.9.0 to 2.9.1.

    Release notes

    Sourced from gson's releases.

    Gson 2.9.1

    • Make Object and JsonElement deserialization iterative rather than recursive (#1912)
    • Added parsing support for enum that has overridden toString() method (#1950)
    • Removed support for building Gson with Gradle (#2081)
    • Removed obsolete codegen hierarchy (#2099)
    • Add support for reflection access filter (#1905)
    • Improve TypeToken creation validation (#2072)
    • Add explicit support for float in JsonWriter (#2130, #2132)
    • Fail when parsing invalid local date (#2134)

    Also many small improvements to javadoc.

    Changelog

    Sourced from gson's changelog.

    Version 2.9.1

    • Make Object and JsonElement deserialization iterative rather than recursive (#1912)
    • Added parsing support for enum that has overridden toString() method (#1950)
    • Removed support for building Gson with Gradle (#2081)
    • Removed obsolete codegen hierarchy (#2099)
    • Add support for reflection access filter (#1905)
    • Improve TypeToken creation validation (#2072)
    • Add explicit support for float in JsonWriter (#2130, #2132)
    • Fail when parsing invalid local date (#2134)

    Also many small improvements to javadoc.

    Commits
    • bb9a1f2 [maven-release-plugin] prepare release gson-parent-2.9.1
    • 893a7e1 Fix malformed JsonElement.getAsBigDecimal() javadoc (#1772)
    • 6d2557d Remove unused package-private FieldAttributes methods (#2162)
    • 2deb209 Make RuntimeTypeAdapterFactory recognize subclasses only conditionally. (#2...
    • 924c496 Bump maven-resources-plugin from 3.2.0 to 3.3.0 (#2157)
    • 503c20b Rename ReflectiveTypeAdapterFactory field inclusion check method (#2121)
    • 0106247 Bump maven-deploy-plugin from 3.0.0-M2 to 3.0.0 (#2148)
    • eeba71c Upgrade to oss-parent 9 (#2149)
    • 2eb3758 Fix RuntimeTypeAdapterFactory (#2139)
    • cbc0af8 Improve lenient mode documentation (#2122)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump maven-shade-plugin from 3.2.4 to 3.3.0

    build(deps): bump maven-shade-plugin from 3.2.4 to 3.3.0

    Bumps maven-shade-plugin from 3.2.4 to 3.3.0.

    Commits
    • 7169fde [maven-release-plugin] prepare release maven-shade-plugin-3.3.0
    • e5dcf95 Revert "[maven-release-plugin] prepare release maven-shade-plugin-3.3.0"
    • c2473cb [maven-release-plugin] prepare release maven-shade-plugin-3.3.0
    • ece4172 Revert "[maven-release-plugin] prepare release maven-shade-plugin-3.3.0"
    • 0c6f823 Revert "[maven-release-plugin] prepare for next development iteration"
    • a9355b3 [maven-release-plugin] prepare for next development iteration
    • fc1dcc2 [maven-release-plugin] prepare release maven-shade-plugin-3.3.0
    • aa019ca Bump hamcrest-core from 1.3 to 2.2
    • 17b87aa [MSHADE-412] avoid possible NPE since rawString was added in SimpleRelocator ...
    • 04afab6 Shared GitHub actions v2
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump maven-shade-plugin from 3.3.0 to 3.4.1

    build(deps): bump maven-shade-plugin from 3.3.0 to 3.4.1

    Bumps maven-shade-plugin from 3.3.0 to 3.4.1.

    Commits
    • fbbec08 [maven-release-plugin] prepare release maven-shade-plugin-3.4.1
    • 7078d92 [MSHADE-413] Fix endless loop caused by manipulating shared objects (#124)
    • 0945bcb [MSHADE-417] Fix null bytes appended to small files (#160)
    • 41bd72f [MSHADE-366] "Access denied" during 'minimizeJar' (#161)
    • e342059 [MSHADE-432] Duplicate services entries can be generated (#159)
    • 7603e57 Bump asmVersion from 9.3 to 9.4 (#156)
    • 5e955d8 Bump maven-dependency-tree from 3.0.1 to 3.2.0 (#148)
    • 5f45ecf [MSHADE-431] Use a caching output stream (#158)
    • 31d3506 Bump plexus-utils from 3.3.0 to 3.4.2 (#139)
    • b039731 [MSHADE-430] Remove usage of deprecated ModelBase#getReports()
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump gson from 2.9.1 to 2.10

    build(deps): bump gson from 2.9.1 to 2.10

    Bumps gson from 2.9.1 to 2.10.

    Release notes

    Sourced from gson's releases.

    Gson 2.10

    Most important changes

    • Support for serializing and deserializing Java records, on Java ≥ 16. (#2201)

    • Add JsonArray.asList and JsonObject.asMap view methods (#2225)

    • Fix TypeAdapterRuntimeTypeWrapper not detecting reflective TreeTypeAdapter and FutureTypeAdapter (#1787)

    • Improve JsonReader.skipValue() (#2062)

    • Perform numeric conversion for primitive numeric type adapters (#2158)

    • Add Gson.fromJson(..., TypeToken) overloads (#1700)

    • Fix changes to GsonBuilder affecting existing Gson instances (#1815)

    • Make JsonElement conversion methods more consistent and fix javadoc (#2178)

    • Throw UnsupportedOperationException when JsonWriter.jsonValue is not supported (#1651)

    • Disallow JsonObject Entry.setValue(null) (#2167)

    • Fix TypeAdapter.toJson throwing AssertionError for custom IOException (#2172)

    • Convert null to JsonNull for JsonArray.set (#2170)

    • Fixed nullSafe usage. (#1555)

    • Validate TypeToken.getParameterized arguments (#2166)

    • Fix #1702: Gson.toJson creates CharSequence which does not implement toString (#1703)

    • Prefer existing adapter for concurrent Gson.getAdapter calls (#2153)

    • Improve ArrayTypeAdapter for Object[] (#1716)

    • Improve AppendableWriter performance (#1706)

    List of all changes

    ... (truncated)

    Changelog

    Sourced from gson's changelog.

    Change Log

    Commits
    • dd92e49 [maven-release-plugin] prepare release gson-parent-2.10
    • 7ca36c5 Add a \<developers> section to the main pom.xml.
    • 79c27dd [maven-release-plugin] prepare for next development iteration
    • 87e9ee5 [maven-release-plugin] prepare release gson-parent-2.10
    • 4705518 Revise the version regex in GsonVersionDiagnosticsTest. (#2228)
    • 7bca5c4 [maven-release-plugin] rollback the release of gson-parent-2.10
    • c7544a0 [maven-release-plugin] prepare for next development iteration
    • 9efdfad [maven-release-plugin] prepare release gson-parent-2.10
    • 4f948dd Automatically replace version references on release:prepare (#2212)
    • 9578583 Small tweaks to fix Error Prone warnings. (#2227)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Owner
Kacper Horbacz
Kacper Horbacz
Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer.

json-io Perfect Java serialization to and from JSON format (available on Maven Central). To include in your project: <dependency> <groupId>com.cedar

John DeRegnaucourt 303 Dec 30, 2022
MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Andrei Ciobanu 59 Sep 17, 2022
A simple java JSON deserializer that can convert a JSON into a java object in an easy way

JSavON A simple java JSON deserializer that can convert a JSON into a java object in an easy way. This library also provide a strong object convertion

null 0 Mar 18, 2022
A compiler built in Java that allows to translate xml format to json.

A compiler built in Java that allows to translate xml format to json. Getting Started Welcome to the VS Code Java world. Here is a guideline to help y

Víctor Andrés Rojas 1 Jan 6, 2022
JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Bazaarvoice 1.3k Dec 30, 2022
Essential-json - JSON without fuss

Essential JSON Essential JSON Rationale Description Usage Inclusion in your project Parsing JSON Rendering JSON Building JSON Converting to JSON Refer

Claude Brisson 1 Nov 9, 2021
A 250 lines single-source-file hackable JSON deserializer for the JVM. Reinventing the JSON wheel.

JSON Wheel Have you ever written scripts in Java 11+ and needed to operate on some JSON string? Have you ever needed to extract just that one deeply-n

Roman Böhm 14 Jan 4, 2023
Configuration library based on annotation processing

net.cactusthorn.config The Java library with the goal of minimizing the code required to handle application configuration. Motivation The inspiring id

Alexei Khatskevich 7 Jan 8, 2023
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back, with a transparent support of any kind of self-references and with a full Java 9 compatibility.

Andrey Mogilev 9 Dec 30, 2021
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 8.7k Dec 31, 2022
A fast JSON parser/generator for Java.

fastjson Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON str

Alibaba 25.1k Dec 31, 2022
Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Logz.io 100 Jan 1, 2023
Genson a fast & modular Java <> Json library

Genson Genson is a complete json <-> java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

null 212 Jan 3, 2023
A reference implementation of a JSON package in Java.

JSON in Java [package org.json] Click here if you just want the latest release jar file. Overview JSON is a light-weight language-independent data int

Sean Leary 4.2k Jan 6, 2023
Fast JSON parser for java projects

ig-json-parser Fast JSON parser for java projects. Getting started The easiest way to get started is to look at maven-example. For more comprehensive

Instagram 1.3k Dec 26, 2022
A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order

Read me first The current version of this project is licensed under both LGPLv3 (or later) and ASL 2.0. The old version (2.0.x) was licensed under LGP

Java Json Tools 1.5k Jan 4, 2023
Lean JSON Library for Java, with a compact, elegant API.

mJson is an extremely lightweight Java JSON library with a very concise API. The source code is a single Java file. The license is Apache 2.0. Because

Borislav Iordanov 77 Dec 25, 2022
JSON-LD implementation for Java

JSONLD-Java is looking for a maintainer JSONLD-JAVA This is a Java implementation of the JSON-LD 1.0 specification and the JSON-LD-API 1.0 specificati

null 362 Dec 3, 2022