Skip to content

Commit

Permalink
Add simple usage information
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubenicos committed Feb 22, 2024
1 parent 075308c commit 59befaf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,22 @@ Currently supporting the formats:
Take in count this library is not focused as an object serializer, the main purpose is making flexible interactions with multiple data formats at the same time.

It also has simple methods to get nodes as multiple data types if you want to implement your own object serializer.

```java
// Load settings from Map
Map<String, Object> map = new HashMap<>();
map.put("key", "value");
map.put("otherkey", 1234);

Settings settings = new Settings();
settings.merge(map);


// Settings from any file named "myfile", the format can be any supported format.
// If file doesn't exist, the optional file "myfile.json" inside .jar will be used.
SettingsData<Settings> data = SettingsData.of("myfile.*").or(DataType.INPUT_STREAM, "myfile.json");
// Load settings by providing a parent folder.
// Also, optional file will be saved inside the folder if original file doesn't exist
File folder = new File("folder");
Settings settings = data.load(folder, true);
```

0 comments on commit 59befaf

Please sign in to comment.