Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Serialized beans have extra parameters in JSON #20

Closed
craigwblake opened this issue Mar 6, 2015 · 5 comments
Closed

Serialized beans have extra parameters in JSON #20

craigwblake opened this issue Mar 6, 2015 · 5 comments

Comments

@craigwblake
Copy link

It appears that when serializing beans that were created with the MrBean module, the output JSON has every property duplicated with a leading underscore. Here's a test case which reproduces the problem:

https://github.com/craigwblake/mrbean-test

The failure is this:

Failed tests: testBean(com.gses.config.ParserTest): expected:<{"[field": ]"testing"}> but was:<{"[_field":"testing","field":]"testing"}>

@cowtowncoder
Copy link
Member

That would definitely be wrong. Thank you for reporting this.

@craigwblake
Copy link
Author

Awesome, thanks for the fast fix!

@cowtowncoder
Copy link
Member

Thanks for reporting it -- I can't believe such an obvious problem wasn't reported earlier... I guess most use cases just involved deserialization.

FWIW, the underlying problem is two-fold:

  1. Backing fields were named _property, AND
  2. Fields were create as public and were visible for serialization

I changed both, although just changing visibility could also have worked.

@rethwischk
Copy link

This problem remains in MrBean 2.7.4.

@cowtowncoder
Copy link
Member

@rethwischk If you still see a similar problem, please file a new issue with reproduction. Also make sure to test with latest 2.7 patch (2.7.7) as sometimes there are relevant fixes.

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

No branches or pull requests

3 participants