-
Notifications
You must be signed in to change notification settings - Fork 0
Path Syntax
frosxt edited this page Jan 18, 2026
·
1 revision
JsonConfig uses a dot-notation syntax to traverse the JSON hierarchy. This allows you to read and modify deeply nested values without retrieving intermediate objects.
The dot . separates keys in a JSON object.
JSON:
{
"server": {
"database": {
"host": "localhost"
}
}
}Access:
String host = config.getString("server.database.host");You can access array elements using brackets [index].
JSON:
{
"users": [
{ "name": "Alice", "id": 1 },
{ "name": "Bob", "id": 2 }
]
}Access:
// Get the name of the first user
String firstUser = config.getString("users[0].name"); // "Alice"
// Helper method to get the ID of the second user
int secondId = config.getInt("users[1].id"); // 2When working with a JsonSection (a subsection of the config), paths are relative to that section.
JsonSection dbSection = config.getConfigurationSection("server.database");
// access 'host' relative to 'server.database'
String host = dbSection.getString("host");