I could not find a native implementation in the library you wanted to use, which can handel this kind of request. So I came up with my own little code snippet which might help you.
private static Object getNestedValue(final String path, JSONObject obj) {
String currentKey;
String currentPath = path;
while (true) {
// Get current key with tailing '.'
currentKey = currentPath.substring(0, currentPath.indexOf('.') + 1);
// Remove the current key from current path with '.'
currentPath = currentPath.replace(currentKey, "");
// Remove the '.' from the current key
currentKey = currentKey.replace(".", "");
// Check if the current key is available
if (obj.containsKey(currentKey))
obj = (JSONObject) obj.get(currentKey); // This can cause an Class Cast exception, handel with care
else if (currentKey.isEmpty()) // Check if the currentKey is empty
return obj.get(currentPath); // Return the result
else
return null;
}
}