Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize arrays (instead of objects) to json #426

Closed
pleerock opened this issue Nov 22, 2014 · 3 comments
Closed

serialize arrays (instead of objects) to json #426

pleerock opened this issue Nov 22, 2014 · 3 comments

Comments

@pleerock
Copy link

We have a restful interface, and jmsserializer is widely used. Most of operations for any rest backend are read-only-operations, and most of time is taking doctrine and query to the db. I imagine that this a flow on the rest point:

request -> controller -> doctrine -> fetch the data from the db (not sure about internals, but probably in array format) -> convert the array to object -> object is passing to the jmsserializer -> serializer converts it to json (hope there is no another conversion to the array internally)

I'm seeing some unnecessary steps in converting the array of data to the object, because I actually dont need this object, Im using it only for jmsserializer to work properly with my annotations on the object's fields.
As we know hydration process of objects in doctrine takes some extra resources, so my question is: can we prevent this step? For example, if we pass an array to the jmsserializer, and classname, it reads all annotations from the given class, but apply operations on the array, not an object (field names and array keys are identical). If there is no such feature yet, maybe someone can implement it?

@schmittjoh
Copy link
Owner

There is certainly room for optimization, but the question imo is whether this is worth it? How much time do we gain?

So far, this does not seem to have been a problem, and it might be more worthwhile to add a caching layer around the final result (the JSON response) than to optimize (and complexify) the process to get there.

@theofidry
Copy link

I think too that it's not really a problem, still it would far more convenient!

@goetas
Copy link
Collaborator

goetas commented Mar 13, 2017

this is what happens with layered systems. each system adds its own layer and its representation.

@goetas goetas closed this as completed Mar 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants