I am trying to pass a file to JSON parser on the unix box like this:
JSONArray a = (JSONArray) parser.parse("/opt/Scheherazade/hegrid.git/hegrid-web/EventsJson.json");
This will run on the unix box. But I get the following error :
Unexpected character (/) at position 0. at org.json.simple.parser.Yylex.yylex(Unknown Source) at org.json.simple.parser.JSONParser.nextToken(Unknown Source) at org.json.simple.parser.JSONParser.parse(Unknown Source) at org.json.simple.parser.JSONParser.parse(Unknown Source) at org.json.simple.parser.JSONParser.parse(Unknown Source) at com.ca.service.ModifyEventJsonFile.replaceActorJsonFile(ModifyEventJsonFile.java:21) at com.ca.controller.ChefController.saveSchzScript(ChefController.java:139) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497)
How to enter the path correctly?
parse.parse(String)assumes that theStringis a JSONString, not a file reference, tryparser.parse(new File("/opt/Scheherazade/hegrid.git/hegrid-web/EventsJson.json"));insteadReader, had to dig the source out...