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

Json serialization include one child property #566

Open
dtelaroli opened this issue Aug 27, 2013 · 5 comments
Open

Json serialization include one child property #566

dtelaroli opened this issue Aug 27, 2013 · 5 comments

Comments

@dtelaroli
Copy link
Contributor

I wanna include only the primary key from all classes.
The include method in json representation not accept include a child property directly.

e.g

result.use(json()).include("myObj.id").serialize();

if I include the root property, all properties will be serializeds, unnecessarily

I think that should be cool have this feature, generating more light jsons without excluding individuals properties.

What do you think? Is it viable?

@garcia-jj
Copy link
Member

Did you try?

result.use(json()).from(myObject).excludeAll().include("myObj.id").serialize();

@dtelaroli
Copy link
Contributor Author

I want to include all from root and id from parents

class MyObj {
   Long id;
   String name;
   MyOther myOther;
   ...
}

class MyOther{
   Long id;
   String description;
}

Preserves excludeAll the root properties?
There is excludeAll documentation?

@garcia-jj
Copy link
Member

I'm sorry, this method is not released yet. And the docs needs improvements to explain better how to use. I'll do this soon.

In your case, what's the expected json?

@dtelaroli
Copy link
Contributor Author

{"myObj": {"id":1, "name": "value for name", "myOther":{"id":1}}

@garcia-jj
Copy link
Member

I'll do tests to see if excludeAll() helps you.

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