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

Customized attributes in JSON #91

Closed
log0 opened this issue Mar 13, 2012 · 4 comments
Closed

Customized attributes in JSON #91

log0 opened this issue Mar 13, 2012 · 4 comments

Comments

@log0
Copy link

log0 commented Mar 13, 2012

Dear all, I'm new to JMS, got a question that I need some help on.

Suppose I have a model that has fields A and B. So serializing that gives only id, A and B, what if I want to expose as a JSON a field C (which is NOT attribute) and is a function of A and B?

e.g.
{"A":2, "B":4, "C":16}
, where C is A^B.

Something like that.

Thanks!!!

@schmittjoh
Copy link
Owner

This is not possible atm.

You need to create either a) a property for C or b) write a custom handler for your object.

@log0
Copy link
Author

log0 commented Mar 13, 2012

Hi @schmittjoh

Thanks for swift response. I didn't clearly understand so I want to repeat to see if I'm right on this:
a) create a property that will be updated on a @PreSerialize event?
b) what's the custom handler you mean? Sorry, could you elaborate a bit?

Thanks!

@stof
Copy link
Contributor

stof commented Mar 13, 2012

@schmittjoh couldn't it be possible if you have a getter for C in the class ?

@schmittjoh
Copy link
Owner

You would still need the property to declare an @Accessor annotation on it.

On Tue, Mar 13, 2012 at 1:03 PM, Christophe Coevoet <
[email protected]

wrote:

@schmittjoh couldn't it be possible if you have a getter for C in the
class ?


Reply to this email directly or view it on GitHub:

#91 (comment)

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

3 participants