other-languages

here be heresies and things we have to use for work
teodorlu 2021-05-14T12:56:43.125800Z

Does jackson (Java) provide a get-in equivalent for lookup on a JsonNode?

teodorlu 2021-05-15T10:37:29.126600Z

In case anyone else are interested, I just wrote it out:

JsonNode current = this.provideJson.get();

        for (String k : key) {
            if (current.hasNonNull(k)) {
                current = current.get(k);
            } else {
                return Optional.empty();
            }
        }

        if (current.isInt())
            return Optional.of(current.asInt());
        else
            return Optional.empty();
Quite straightforward.

teodorlu 2021-05-15T10:38:01.126800Z

Different methods for different types. I didn't bother with generics.

osi 2021-05-15T20:24:47.127Z

JsonNode#at is it’s built-in equivalent

💯 1
1
teodorlu 2021-05-16T13:05:39.127400Z

Thanks!