Why is Jongo unable to unmarshall a NumberLong?

71 views
Skip to first unread message

Nav

unread,
Mar 23, 2016, 10:02:08 AM3/23/16
to Jongo

I have a record like this:

{
    "_id" : ObjectId("56eec1271abfdsfsgdfy434kb"),
    "gender" : "Male",
    "addressList" : [ 
        {
            "locId" : NumberLong(1),
            "city" : "Somewhere"
        },
    ]
}

When unmarshalling with Jongo in Java, the locId results in a 0 if I use long and it results in a null if I use Long.

I know there is a specific way of unmarshalling ObjectId's, but how does one do it for NumberLong?

The classes I'm unmarshalling it into are:

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.Date;
import java.util.List;
import org.jongo.marshall.jackson.oid.ObjectId;

public class Collection_Profile {

    @ObjectId
    @JsonSerialize(using = NoObjectIdSerializer.class)
    public String _id;
    public String gender;
    public List<Collection_AddressList> addressList;   
}

and

public class Collection_AddressList {
    public long locID;
    public String city;
    public String state;
}

The city name is being unmarshalled perfectly.

Nav

unread,
Mar 24, 2016, 2:32:48 AM3/24/16
to Jongo
Ok it turned out to be a case mismatch. I was using "locID" instead of "locId".
Problem solved.

Benoît Guérout

unread,
Mar 24, 2016, 4:25:11 AM3/24/16
to jongo...@googlegroups.com
Ok cool.
The "wrong" field seems indeed handled as null

--
You received this message because you are subscribed to the Google Groups "Jongo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jongo-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages