Skip to content

Commit

Permalink
📚️ docs: add example usage
Browse files Browse the repository at this point in the history
Added example usage of the library and made a better TODO list.
  • Loading branch information
retrozinndev authored Feb 2, 2024
1 parent 2ad5a78 commit aa7cbca
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
A simple JSON Library for java, still in development.

### TODO:
- Add JSON variables to file
- Check each line for searching variables
- ... many more
- Add JSON variables to file;
- Read file for existing variables before writing new ones;
- Only write when `JSONBuilder.makeJSON()` is called;
- Make a JSONFormatter class.

### Usage
Here's an example usage of JSONutils:
```java
JSON jsonFile = new JSONBuilder("/directory/file.json").newVariable("IsLibraryComplete", false).makeJSON();
```
**Explanation**:
- `jsonFile` is an instance of the JSON class;
- `jsonFile` is instantiated using JSONBuilder for adding variables and building the JSON using `makeJSON()`;
- `JSONBuilder` has(not yet) many methods to build a JSON file, such as `newVariable(String key, Object value)`, and `makeJSON()`;
- `JSONBuilder` is extended from the `JSON` class;
- `makeJSON()` has to be used in the end of the line;
- `newVariable()` adds the variable to a HashMap, which in `makeJSON()` will be written to a file, just like `Writer.flush()`.

0 comments on commit aa7cbca

Please sign in to comment.