Closed ManueGE closed 6 years ago
Hello,
I don't seem to understand correctly the request. Can you give a more concrete example?
Thanks
Sure, let's suppose we have a class User
(with id
and name
). I got this JSON:
[
{"id": 1, "name": "John"},
{"id": 2, "name": "Mary"},
{"id": 3, "name": "Michael"}
]
I can write a PreProcessor/PostProcessor to intercept each one of the jsons within the array before/after convert them to Users
, but I would like to have one PreProcessor to intercept the full JSON array at once.
Does it makes more sense?
Oh ok, got it now.
I think the way to do this is to add a new feature to the GsonFireBuilder
to allow registering processors to a TypeToken
.
So you would do:
gsonFireBuilder.registerPreProcessor(new TypeToken<List<user>>(){}.getType(), /* here the preprocessor */);
I'll play with that approach during the weekend and give you an update here
That would be awesome. Thanks :)
I think I found a ~not so pretty~ way to make it work:
Try this:
gsonFireBuilder.registerPreProcessor((Class<List<User>>)new TypeToken<List<User>>(){}.getRawType(), /* here the preprocessor for List<User>*/);
Thanks you very much. I'll give it a try :)
You can close the issue.
May it possible adding a preprocessor/postprocessor to make some changes before/after inserting an array of objects?
I mean, something like this:
Any chance to be added in the future?