For some JSON:
{ "id":123, "name":"Test", "sub_object":{ "sub_field_1":1, "sub_field_2":2, "sub_field_array":[ { "array_field_1":true, "array_field_2":false }, { "array_field_1":false, "array_field_2":true } ], "sub_sub_object":{ "field_1":"me", "field_2":"myself", "field_3":"i", } } }
I want to apply a tree-like list of field names. This can probably be expressed in JSONPath:
root |-id |-sub_object |-sub_field_2 |-sub_field_array |-array_field_1 |-sub_sub_object
Then I need to return something like:
{ "id":123, "sub_object":{ "sub_field_2":2, "sub_field_array":[ { "array_field_1":true }, { "array_field_1":false } ], "sub_sub_object":{ "field_1":"me", "field_2":"myself", "field_3":"i", } } }
The idea is that for some hierarchy of fields I want to limit the displayed fields.
I do this through a library that annotated the fields of its objects, but I cannot change the library. Actually, that would not matter, because the hierarchy would be based on serialization. I am currently passing objects to the writeObject method of JsonGenerator, but this returns everything.
Some sub-objects can share field names, so this is not as simple as creating a SimpleBeanPropertyFilter to serialize only a set of names.
Thank you in advance,
John