Closed javamonkey79 closed 8 years ago
Digging deeper, I would have expected this to work but did not:
JsonSerializer jsonSerializer = new JsonSerializerFactory().setIncludeEmpty(false).create();
System.out.println(jsonSerializer.serialize(mittens));
Ok, I see now that the includeEmpty property pertains to collections. I also see that StringSerializerImpl is where blank String checking would occur. However, it appears there is no way to inject in subclasses in to the factory? I think if you refactored the create method to read from protected methods, this would not be an issue: users could then subclass the factory and provide a version that suits their needs.
I've completed a simple version and issued a pull request: https://github.com/boonproject/boon/pull/356
I'm curious, is there something else I need to do here to get this rolled in?
Let me look at your pull request. Been busy is all. :)
I merged your request. It will get released the next time @slandelle does a release. If I remember correctly, I am not setup to do a release.
Cool, thanks for merging it in @RichardHightower . @slandelle do you have an ETA on a release?
Done :)
@RichardHightower Are there some patches here that needs to be ported on https://github.com/advantageous/boon?
@RichardHightower wdyt about this type of behavior as default?
Probably should be.
Ok, I'll submit a pull later then.
Sent with AquaMail for Android http://www.aqua-mail.com
On September 1, 2016 1:54:08 AM Richard Hightower notifications@github.com wrote:
Probably should be.
You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/boonproject/boon/issues/355#issuecomment-244017477
Ok, I've pushed my changes and submitted a pull request @RichardHightower
looking now
Consider this case:
public class Cat { public String name; public String type; public String sex; //... constructor, etc omitted for brevity } Cat mittens = new Cat("mittens", "calico", "");
In this case, Boon.toJson(mittens) will give us:
{ "name":"mittens", "type":"calico", "sex":"" }
Is there any way to ignore empty values? If not, will you consider a patch to allow for this?