JsonFile is a Kotlin JSON API that simplifies the creation and modification of JSON files. It takes a URL as an input and retrieves the JSON file from there. It also supports interoperability with Java and all Java versions. JsonFile allows you to easily read, write, update and delete data from JSON files using Kotlin syntax and features.
UPDATES
Version | About | Can get it |
---|---|---|
V1.5.0 | Major update and added YamlFiles | ✅ |
V1.4.9 | Fixed bug about JsonUrl | ✅ |
V1.4.8 | Fixed bug about JsonUrl | ✅ |
V1.4.7 | Fixed bug about JsonUrl | ✅ |
V1.4.6 | JsonUrl added | ❌ |
V1.4.4 | Added automated Directory creation | ✅ |
V1.4.3 | Dependecy support added | ✅ |
V1.5.0 Bug fix and major update, added YamlFile and url, ability to convert from json to yaml and vice versa
V1.4.9 Bug fix and release
V1.4.8 Bug fix and release
V1.4.7 Bug fix and release
V1.4.6 Added the possibility to convert Json files fron url to a JsonFile class
V1.4.4 Added automated directory creation, to prevent any errors
V1.4.3 Dependecy support, so you can use JsonFile in your project
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.SpreestDev</groupId>
<artifactId>JsonFile</artifactId>
<version>V1.5.0</version>
</dependency>
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.SpreestDev:JsonFile:V1.5.0'
}
Initialization of the class:
JsonFile file = new JsonFile("file");
Map<String, Object> defaults = new HashMap<String, Object>() {
{
put("a", "1");
put("b", "2");
put("c", "3");
put("d", "4");
put("e", "5");
put("f", "6");
}
};
if(!file.exists()) {
file.create((HashMap<String, Object>) defaults);
}
System.out.println(file.getString("a"));
val file2 = JsonFile("file")
val defaults = hashMapOf<String, Any>(
"a" to "1",
"b" to "2",
"c" to "3",
"d" to "4",
"e" to "5",
"f" to "6"
)
if (!file2.exists()) {
file2.create(defaults)
}
println(file2["a"])
To get a class:
JsonFile file = new JsonFile("file");
Car car = (Car) file.getObject("obj", Car.class);
assert car != null;
System.out.println(car.getModel());
val file = JsonFile("file")
val car = (file.getObject("obj", Car::class.java) as Car?)!!
println(car.model)
- Automate directory creation
- Read json url