https://github.com/cakemc-network/veric
:heart: json/properties like config/meta library
https://github.com/cakemc-network/veric
Last synced: 12 months ago
JSON representation
:heart: json/properties like config/meta library
- Host: GitHub
- URL: https://github.com/cakemc-network/veric
- Owner: CakeMC-Network
- License: apache-2.0
- Created: 2025-01-18T17:26:12.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-02-23T22:01:58.000Z (over 1 year ago)
- Last Synced: 2025-02-23T23:18:19.282Z (over 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 80.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# custom config/meta system inspired by json/yaml/toml
Custom Configuration system based on lexical analyses to retrieve a key/value like scheme system
### Kotlin (JVM) example usage of the api:
```kotlin
package test
import net.cakemc.veric.Veric
import java.nio.file.Paths
fun main() {
val veric = Veric()
// defaults:
veric.setString("string", "Hello, World!")
veric.setInteger("integer", 100)
veric.setDouble("double", 123.123)
veric.setFloat("float", 12345F)
veric.setLong("long", 1111111111111111111L)
veric.setChar("char", 'A')
veric.setBoolean("boolean", true)
// lists:
val list = listOf("first", "last", "third")
veric.setList("list", list)
// objects "endless" nesting possible (object in object in....)
val complex = Veric()
complex.setString("name", "Hi")
complex.setInteger("age", 21)
complex.setList("activity", listOf("gaming", "music"))
veric.setObject("object", complex)
// save it to a file
veric.saveToFile(Paths.get("./example.veric"))
// load a Veric object from file
val loaded = Veric.readFile(Paths.get("./example.veric"))
// get defaults:
println(veric.getString("string"))
println(veric.getInteger("integer"))
println(veric.getDouble("double"))
println(veric.getFloat("float"))
println(veric.getLong("long"))
println(veric.getChar("char"))
println(veric.getBoolean("boolean"))
// lists:
println(veric.getList("list"))
// get the saved object and print it in the custom format
println(loaded.getObject("object").toVericString())
// contains check
println(veric.has("double"))
// printing all keys
println(veric.keySet())
// delete a key/value
veric.delete("char")
// print the whole object with formating
println(veric.toVericString())
}
```
### OUTPUT:
```
string = "Hello, World!"
integer = 100
double = 123.123
float = 12345.0
long = 1111111111111111111
char = 'A'
boolean = true
list = [
"first"
"last"
"third"
]
object = {
name = "Hi"
age = 21
activity = [
"gaming"
"music"
]
}
```
### Another example:
```
test = {
name = "tom"
age = 21
activity = [
"programming"
"cars"
]
contact = {
email = "example@test.com"
company = "CakeMC"
}
}
```