java - JSONParser: Unexpected token COLON(:) -
I am trying to parse a JSON file with JSONParse and am receiving the error, the following Jason Initially with error:
Unexpected token colon in position 11.
{ "276716878": { "followers": [2435018580, 1664252310, 372262434], "following": [16211434, 945 440 9 5, 130682467, 264257750, 900526363, 318231688, 40335029, 64044676 ]}} I have written json file with the following:
FileWriter out = new FileWriter (JSON_FILE); Out.write (json.toString (1)); Out.flush (); Out.close ();
You may have some format error in passing Jason string. . The sample code works fine below
import java.io.fileWriter; Import java.io.IOException; Import java.util.logging.Level; Import java.util.logging.Logger; Import org.json.JSONException; Import org.json.JSONObject; Public class test {private static final logger logger = logger.getlogger (test.clash.jetname ()); Private static final string JSON_FILE = "/home/visruth/Desktop/Visruth.txt"; Public static void main (String [] Arges) {string jsonText = "{\" 215876567 \ ": {\" followers \ ": [2464054938, 772 677 937]}}"; Try (FileWriter out = new FileWriter (JSON_FILE);) {JSONObject json = new JSONObject (jsontext); Int IndentFactor = 1; String per printed generic = jason.trusting (indentfactor); Println (prettyprintedJSON); Out.write (prettyprintedJSON); } Hold (JasonXEpisode E) {logger.log (Level.SSEEEE, EMMsages ()); } Hold (IOException e) {logger.severe (e.getMessage ()); }}} Specify your Jason text in the jsontext variable and try it.
Comments
Post a Comment