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 to array #518

Closed
tarjei opened this issue Nov 5, 2015 · 6 comments
Closed

Serialize to array #518

tarjei opened this issue Nov 5, 2015 · 6 comments

Comments

@tarjei
Copy link
Contributor

tarjei commented Nov 5, 2015

Hi, one thing I often miss is the option to serialize something to an array.

Usecases are:

  • Appending the serialized values to a bigger array so I can use different serializationcontexts to different parts of the object graph.
  • Testing

Is this a feature you would consider?

@afurculita
Copy link

This feature has been already included in the library:

https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/Serializer.php#L116

@tarjei
Copy link
Contributor Author

tarjei commented Nov 29, 2015

Yes, I saw that. I would like to suggest that ->serialize($obj, 'array') to that method, but apart from that I'll close this issue :)

T

@tarjei tarjei closed this as completed Nov 29, 2015
@Aliance
Copy link
Contributor

Aliance commented Jan 10, 2017

->serialize($obj, 'array') looks good. Needs just to extend GenericSerializationVisitor.
@schmittjoh @goetas is there any necessity in it? I can make a pr with my solution. Or using Serializer::toArray is enough?

@goetas
Copy link
Collaborator

goetas commented Jan 10, 2017

@Aliance $serializer->serialize($obj, 'array') and $serializer->toArray($obj) have different semantics.

  • $serializer->serialize($obj, 'array') use the array visitor.. (that does not exists...)
  • $serializer->toArray($obj) is a "specific" feature of the serializer to return the array representation using the json visitor.

Will prefer to not introduce more "special" cases

@Aliance
Copy link
Contributor

Aliance commented Jan 10, 2017

use the array visitor.. (that does not exists...)

I understand & my proposal was to create it. By your comment, I was not able to clearly understand for you or not?

@goetas
Copy link
Collaborator

goetas commented Jan 10, 2017

no, prefer to keep it as it is now. thanks :)

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