java - Exception while parsing JSON using org.simple -
i creating json file , saving location. when files creating first time, there no issues. if file exists , should update existing json file in same location getting following exception:
exception:
unexpected character (-) @ position 138. @ org.json.simple.parser.yylex.yylex(unknown source) @ org.json.simple.parser.jsonparser.nexttoken(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ nbclearn.edgate.executorservice.execservice$1.run(execservice.java:116) @ unexpected character (d) @ position 123. @ org.json.simple.parser.yylex.yylex(unknown source) @ org.json.simple.parser.jsonparser.nexttoken(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ nbclearn.edgate.executorservice.execservice$1.run(execservice.java:116) @ unexpected token end of file @ position 0. @ org.json.simple.parser.jsonparser.parse(unknown source) @ org.json.simple.parser.jsonparser.parse(unknown source) @ nbclearn.edgate.executorservice.execservice$1.run(execservice.java:116) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:745)
file writting:
bufferedwriter writer = new bufferedwriter( new outputstreamwriter(new fileoutputstream("/users/smo/desktop/ed/"+id+".json"), "utf-8")); try { writer.write(jsondata); } system.out.println("done"); } { writer.close(); }
i using org.simple libraru see if json file exists in location , else should create new file. if exists should update it.
code checking json file:
path p = paths.get("/users/smo/desktop/ed/"+id + ".json"); boolean exists = files.exists(p); if(exists){ object obj = parser.parse(new filereader( "/users/smo/desktop/ed/"+id + ".json")); org.json.simple.jsonobject jsonobject = (org.json.simple.jsonobject) obj;
json data:
{“id1-position-backstik”: [“4289998”, "422212998", "49998", “638737”],”sum”:2a7c0d20-baf1-4c37-8ac5-eb14198eed06,”position”:1 } }
can please suggest.thanks in advance.
Comments
Post a Comment