KeenClient-Java
KeenClient-Java copied to clipboard
Deal with __fake_root
In order to deal with HTTP responses that can contain either a root JSON Object or a root JSON Array, at a low level we have to check the structure and either return a Map<> or a List<>. That fundamentally changes some of the core code across the SDK, so we added __fake_root to circumvent this without a breaking change.
Look at addressing this in a better way with a breaking change for the next major version bump.
From PR #96 :
// TODO : We can't assume the top-level node is a JSON Object anymore, because parts of the
// API we access return a JSON Array as the root. So we need to detect the type and decide
// what to return, so we need a different return type. Technically it could be a List or
// Map, so it should be Object, then client code would need to do the instanceof check. For
// now, so as to not break the KeenJsonHandler interface, we can we can stick a dummy "root"
// key in the map we pass back.