Skip to content

Commit aa7cbca

Browse files
authored
📚️ docs: add example usage
Added example usage of the library and made a better TODO list.
1 parent 2ad5a78 commit aa7cbca

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
A simple JSON Library for java, still in development.
33

44
### TODO:
5-
- Add JSON variables to file
6-
- Check each line for searching variables
7-
- ... many more
5+
- Add JSON variables to file;
6+
- Read file for existing variables before writing new ones;
7+
- Only write when `JSONBuilder.makeJSON()` is called;
8+
- Make a JSONFormatter class.
9+
10+
### Usage
11+
Here's an example usage of JSONutils:
12+
```java
13+
JSON jsonFile = new JSONBuilder("/directory/file.json").newVariable("IsLibraryComplete", false).makeJSON();
14+
```
15+
**Explanation**:
16+
- `jsonFile` is an instance of the JSON class;
17+
- `jsonFile` is instantiated using JSONBuilder for adding variables and building the JSON using `makeJSON()`;
18+
- `JSONBuilder` has(not yet) many methods to build a JSON file, such as `newVariable(String key, Object value)`, and `makeJSON()`;
19+
- `JSONBuilder` is extended from the `JSON` class;
20+
- `makeJSON()` has to be used in the end of the line;
21+
- `newVariable()` adds the variable to a HashMap, which in `makeJSON()` will be written to a file, just like `Writer.flush()`.

0 commit comments

Comments
 (0)