java - JSON Parsing Exception: Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '"' (code 0x22) in base64 content -
using jackson , i'm trying encode data in json & it's giving exception.
i tried string data & byte[] data:
string representation of same data here: bytes converted string-------->> { "appname": "aaa", "devicetype": "diehdcj", "reporteddate": "2015-05-03t15:38:45+00:00", "sessionid": "5366372183482-6736-23562378", "deviceid": "2151272389", "commandname" : "wqgduwusdue", "protocolversion" : "0.1", "protocolname" : "whjs_ashk_ask", "data" : "false" }
java
16:50:46.065 [] [] error aaatshconnector [http-apr-10.40.120.85-80-exec-3] - json parsing exception: failed decode value_string base64 (mime-no-linefeeds): illegal character '"' (code 0x22) in base64 content
here's code parsing:
java
@consumes(mediatype.application_json) @produces(mediatype.application_json) public response retrievedevicepassword(inputstream request, @context httpservletrequest servletrequest) throws badrequestexception, validationexception, unknownserverexception { objectmapper objectmapper = new objectmapper(); demorequest req = null; demorequest res = null; byte[] data = null; data= ioutils.tobytearray(request); demorequest = objectmapper.readvalue(data, demorequest.class); //it's exception occurs
java
//snippet of pojo @xmlrootelement(name = "demorequest") @jsoninclude(include.non_empty) public class demorequest { private string commandname; private string sessionid; private byte[] data; //getters & setters }
amazingly when try convert same string or byte[] little change in actual content "data" : "true" , works.
can please help
found solution, don't know what's doing: if place escape character in front of false, "data" : "\false" , works fine.
what explanation that?
json parsing exception: failed decode value_string base64 (mime-no-linefeeds): illegal character '"' (code 0x22) in base64 content
the above exception comes in when property of type byte[] , json content represented in string. jackson thinks in case json data represented base64 encoded , tries decode byte[]. if string present in data field isn't encoded base64 string, jackson raises above exception.
Comments
Post a Comment