Skip to content

Problem with FilteringGeneratorDelegate wrt TokenFilter.Inclusion.INCLUDE_NON_NULL #1023

@honhimW

Description

@honhimW
class Entity {
    Pojo[] pojos;
}
class Pojo {
    String id;
    String name;
}

public static void main(String[] args) {
// ...
    JsonGeneratorDelegate delegate = new FilteringGeneratorDelegate(
            generator,
            new JsonPointerBasedFilter(JsonPointer.compile("/pojos/0/name")),
            TokenFilter.Inclusion.INCLUDE_NON_NULL,
            true);
// ...
}

But error occur if TokenFilter#filterStartArray not returning the very TokenFilter.INCLUDE_ALL.

Current context not Array but Object (through reference chain: xxx.xxx.Xxxx["xx"])

I note that FilteringGeneratorDelegate#writeStartArray(Object, int) does not invoke delegate.writeStartArray(forValue, size) when returning JsonGeneratorDelegate itself.
Am i misunderstanding the usage of TokenFilter? And how can i filter properties like this?
Sincerely looking forward to your reply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions