Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Unmarshalling JSON with unknown property with null value

I'm using MOXy to unmarshall incoming JSON to my Jersey API. I have a POJO with three properties: databaseName, initialQuery, and runQueryAsUser. I have a client sending me a POST where the JSON has an additional property that I don't need, secureQuery. When the value of secureQuery is null, MOXy spits back a null object. When the value of secureQuery is the empty string, MOXy returns a valid object with the three properties set and secureQuery correctly ignored. The only annotation the POJO has is `@XmlRootElement(name = "InitialQuery")`.

What gives? 

Version:
    jersey-media-moxy: 2.6
        org.eclipse.persistence.moxy: 2.5.0

Method Signature:

    public Response createSecuredQuery(final InitialQueryBean initialQuery) {

Null InitialQuery object:

    {
        "databaseName":"MyDatabase",
        "initialQuery":"select 1",
        "runQueryAsUser":"bob",
        "secureQuery":null
    }

Good InitialQuery object:

    {
        "databaseName":"MyDatabase",
        "initialQuery":"select 1",
        "runQueryAsUser":"bob",
        "secureQuery":""
    }


Back to the top