I want to implement a function that takes an json as argument as well as an access formula which describes the path to a property.
public String accessJsonDynamically(JSONObject json, String formula) {
    //
}
For example the a[0].b.prop1 along with the example json should return foo. 
 {
    "a": [{
        "b": {
            "prop1": "foo",
            "prop2": "bar"
        }
    }, {
        "c": {
            "prop1": "bar"
        }
    }],
    "d": 3
}
 
    