KeenClient-Java icon indicating copy to clipboard operation
KeenClient-Java copied to clipboard

Deal with __fake_root

Open masojus opened this issue 8 years ago • 1 comments

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.

masojus avatar May 17 '17 06:05 masojus

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.

masojus avatar May 17 '17 06:05 masojus