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 Serializer #40

Closed
dtodt opened this issue Aug 9, 2015 · 3 comments
Closed

Json Serializer #40

dtodt opened this issue Aug 9, 2015 · 3 comments

Comments

@dtodt
Copy link

dtodt commented Aug 9, 2015

So, whats the deal with the JsonSerializer class? Just asking.

I think you can serialize the UserEntity with the UserEntityJsonMapper, just adding the serializer methods.

I've found another way do use the gson, without use the Type.
Source: http://stackoverflow.com/a/17300003/1703546

I've changed the class methods, and ran the tests and is working fine.

Entity:

UserEntity userEntity = this.gson.fromJson(userJsonResponse, UserEntity.class);

Entity Collection:

final UserEntity[] userEntityArray = this.gson.fromJson(userListJsonResponse, UserEntity[].class);
userEntityCollection = new ArrayList<>(Arrays.asList(userEntityArray));

@android10
Copy link
Owner

"So, whats the deal with the JsonSerializer class? Just asking."
It is just a wrapper around gson, in order to not depend on external libraries, thus if you wanna change the serializer you just modify that class.

@dtodt
Copy link
Author

dtodt commented Aug 10, 2015

I've already did that, my question was if this separation was intentional.

In this case, would be a good practice, the serialization be in one class, and the deserialization in another?
Or put all json handle methods in one class.

@android10
Copy link
Owner

For now this fit my needs. I do not want to overthink about this for now. You can refactor later if your class starts becoming a god class.

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