Overriding JsonApiMapper - serializing JsonApiDocument directly #2608
kelseybrennan
started this conversation in
Ideas
Replies: 2 comments
-
On first glance, I agree that it might make more sense to invoke the mapper directly rather than first converting to a JsonNode. It doesn't look like the refactor would be too difficult or break any public API contract. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Check out #2618 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, my team has been using Elide for a while and it works really well for our needs. The main issue that we've had is some complaints from users about the response time for large queries which we've pinpointed to the JSON serialization time.
I saw that it's quite easy to override JsonApiMapper in the ElideSettings to provide a custom mapper, and I have implemented that now. However, I noticed that despite exposing
String writeJsonApiDocument(final JsonApiDocument jsonApiDocument)
, the method that is actually always called when serializing the response isString writeJsonApiDocument(final JsonNode node)
.https://github.com/yahoo/elide/blob/master/elide-core/src/main/java/com/yahoo/elide/Elide.java#L662
I see that the responses are built using JsonApiDocument but then converted to a JsonNode:
https://github.com/yahoo/elide/blob/master/elide-core/src/main/java/com/yahoo/elide/jsonapi/parser/state/CollectionTerminalState.java#L113
I was wondering if there's been any thought around providing the JsonApiDocument directly to the serializer? The JsonApiDocument object is certainly easier to work with when writing a custom serializer, and my current implementation converts the JsonNode back into a JsonApiDocument, so there's a lot of wasted conversion time there.
Beta Was this translation helpful? Give feedback.
All reactions