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

Class name not reflecting in serialized json #662

Closed
archana27m opened this issue Oct 27, 2016 · 3 comments
Closed

Class name not reflecting in serialized json #662

archana27m opened this issue Oct 27, 2016 · 3 comments

Comments

@archana27m
Copy link

I am trying to serialize object to json using following code but unable to get class name in json as root name.

$obj = new Test(array("Name"=>"ABC");

when I try to serialize it with jms serializer,
it shows json output as { "Name" : "ABC" } , Expected output is as { "Test" : { "Name" : "ABC"} }

Please help me for this solution.

@goetas
Copy link
Collaborator

goetas commented Oct 27, 2016

Can you add more details? As example annotations present on the test class?

@goetas
Copy link
Collaborator

goetas commented Oct 29, 2016

Please have a look to http://jmsyst.com/libs/serializer

Your example requires a custom handler probably

@goetas goetas closed this as completed Oct 29, 2016
@archana27m
Copy link
Author

archana27m commented Nov 3, 2016

There are no annotations added for test class, I will add up one if it will give class name in seriazed json but I could not get it. I checked with custom handling but that does not specify class name representation in json. Also if there will be hierarchy for classes for example,
{ "TestOne" : { "Name":"ABC", "Description": {"size":"500px", "color":"blue"}}}

will it be possible by using any of the annotations in per class, in case of above example for class TestOne and Description. Please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants