java - "null" value failing to serialize -
i using jersey client access rest service.
i using jsonobject
, setting "null" literal in it. fails while serialized.
upon investigating, found jsonnull.equals()
method has "null".equals(value)
considers value jsonnull
object.
and then, jsonnull#isempty()
throws exceptions.
net.sf.json.jsonobject params = new net.sf.json.jsonobject(); params.put("pghidentifie", "null");
and when serialized throws:
caused by: com.sun.jersey.api.client.clienthandlerexception: org.codehaus.jackson.map.jsonmappingexception: object null (through reference chain: net.sf.json.jsonobject["pghidentifie"]->net.sf.json.jsonnull["empty"])
how can serialize "null" value inside jsonobject? thanks!
defaultclientconfig defaultclientconfig = new defaultclientconfig(); defaultclientconfig.getclasses().add(jacksonjsonprovider.class); client client = client.create(defaultclientconfig); webresource webresource = client.resource(apiurl); clientresponse response = webresource.path(apiurl).accept("application/json") .type("application/json").post(clientresponse.class, params);
Comments
Post a Comment