Java JSON-Config-File is a simple GSON based implementation to save Objects or primitive values like in a property .ini file.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src/de/roth/json/config
README.md
config.json

README.md

json-config-file

Java JSON-Config-File is a simple GSON based implementation to save objects or primitive values. It's an easy and simple alternative to property files. Download the Config.java and the GSON-Lib and feel free to edit the dummy attributes.

Usage

package de.roth.json.config;

public class Test {

	public static void main(String[] args) {
		// Load config from file
		Config.load("config.json");

		// Access attributes
		Config.getInstance().TITLE = "Neuer Titel";
		Config.getInstance().RATIO = 0.4;
		for (String s : Config.getInstance().NAMES) {
			System.out.println(s);
		}

		// And save it! - done
		Config.getInstance().toFile("config.json");
	}
}

Output

Example output...

 {
  "TITLE": "Neuer Titel",
  "WIDTH": 800,
  "HEIGHT": 600,
  "RATIO": 0.4,
  "NAMES": [
    "Peter",
    "Paul"
  ]
}