JMSSerializerBundle icon indicating copy to clipboard operation
JMSSerializerBundle copied to clipboard

Modify result

Open fnxnet opened this issue 9 years ago • 2 comments

I was looking for way how to modify already serialized data.

I've registered PostSerialize event listener. Unfortunately I have no access from inside of the listener to "data" and modify it (unset variables, wrap data, etc...). I guess it would be greate to have getData() and setData() methods in JMS\Serializer\JsonSerializationVisitor.

What I was trying to archieve is to wrap serialized data like:

[
    'test' => [
        'foo' => 'bar'
    ]
]

into 'parent' to get:

[
    'parent' => [
        'test' => [
            'foo' => 'bar'
        ]
    ]
]

If you get any bether idea plese let me know.

fnxnet avatar Jul 17 '15 15:07 fnxnet

Any idea how I can obtain required result?

fnxnet avatar Jul 30 '15 08:07 fnxnet

I'm curious about this as well. It seems like a trivial method, but maybe it's missing for a reason?

lobboblaw avatar Apr 19 '18 18:04 lobboblaw