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

Force uppermost level of output json as object #555

Closed
NikitaKharkov opened this issue Mar 21, 2017 · 4 comments
Closed

Force uppermost level of output json as object #555

NikitaKharkov opened this issue Mar 21, 2017 · 4 comments

Comments

@NikitaKharkov
Copy link

So my problem is to set force all outputs as objects like next example:

{ <-- always 
  [
      // some data
  ]
} <-- always

Can you advice me how to do that? I deep into the core, I read many issues about this and all tell about back problem "How to convert object to array".
I think it could be done by setting root, but I don't understand how can I global to do that...

I use FOSRestBundle with jms annotations.

@goetas
Copy link
Collaborator

goetas commented Mar 21, 2017

addressed in schmittjoh/serializer#728

@NikitaKharkov
Copy link
Author

Can I implement this for now or I have to wait for new realise? And if I could can give little tutorial how to make this in global state? Thanks.

@goetas
Copy link
Collaborator

goetas commented Mar 21, 2017

you can try the PR, but since is still in work progress, it might change.

And if I could can give little tutorial how to make this in global state?

i'm not sure what you mean as "global state". data are serialized depending on how you configure them.

If you want something as:

{  
  prop: [
      // some data
  ]
} 

you can use a wrapper object for all your responses.

but

{ <-- always 
  [
      // some data
  ]
} <-- always

syntactically is not correct, you need to have some property (prop from the previous example) to have it at least statically correct

@goetas goetas closed this as completed Mar 21, 2017
@NikitaKharkov
Copy link
Author

Newbie mistake of understanding json format... Sorry. Many thanks for quick answer!

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

2 participants