Skip to content

Java JSON-Config-File is a simple GSON based implementation to save Objects or primitive values like in a property .ini file.

Notifications You must be signed in to change notification settings

frankred/json-config-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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"
  ]
}

About

Java JSON-Config-File is a simple GSON based implementation to save Objects or primitive values like in a property .ini file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages