java - Unable to get JSON Object in request to the servlet -
i have created json object manually using data obtained in java script , sent json object servlet using ajax.
the object able receive unable convert json object again. using json-simple-1.1.jar .
i tried
jsonobject json=(jsonobject)new jsonparser().parse("json_data");
but ended following error
aug 31, 2015 2:28:13 source.main.updatedetails doget severe: null unexpected character (j) @ position 0. @ org.json.simple.parser.yylex.yylex(yylex.java:610) @ org.json.simple.parser.jsonparser.nexttoken(jsonparser.java:269) @ org.json.simple.parser.jsonparser.parse(jsonparser.java:118) @ org.json.simple.parser.jsonparser.parse(jsonparser.java:81) @ org.json.simple.parser.jsonparser.parse(jsonparser.java:75) @ source.main.updatedetails.processrequest(updatedetails.java:55) @ source.main.updatedetails.doget(updatedetails.java:107) @ javax.servlet.http.httpservlet.service(httpservlet.java:621) @ javax.servlet.http.httpservlet.service(httpservlet.java:722) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.netbeans.modules.web.monitor.server.monitorfilter.dofilter(monitorfilter.java:393) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:225)
the output of json file sent request follows :
{ "0": { "card_name":"pallela.manga", "aadhar_eid":"1046106160065750110728131521", "aadhar_uid":"693228374919", "relation":"self", "age":"43" }, "1": { "card_name":"kondababu", "aadhar_eid":"1046106160008020110728125714", "aadhar_uid":"996251988555", "relation":"husband", "age":"47" }, "2": { "card_name":"srinivasarao", "aadhar_eid":"1046106125348220110728131743", "aadhar_uid":"609986909901", "relation":"son","age":"25" }, "3": { "card_name":"ganesh", "aadhar_eid":"1046106160002957110728132026", "aadhar_uid":"603873912563", "relation":"son", "age":"23" } }
please me out of this.. thank you
you passing literal string
function, not actual data:
jsonobject json = (jsonobject) new jsonparser().parse("json_data"); // ^^^^^^^^^^^
it should be:
jsonobject json = (jsonobject) new jsonparser().parse(json_data);
assuming json_data
variable contains string
json data
Comments
Post a Comment