I have a simple user class with a Double[] variable for specifying a user's location.
@Document
public class User {
private long id;
private Double[] location;
}
This is the code that i have tried with to serialize my User object
new JSONSerializer()
.transform(new ArrayTransformer(), Double[].class)
.serialize(object));
But the location field won't get serialized, other fields are serialized though.. Could someone please help?
Thanks!
Just declaring the variable isn't enough since it's initialized to null
by default.
Either set a value using setter method or initialize it with and empty array, for example:
private Double[] location = new Double[10];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With