What would be the easiest way to load a file containing JSON into a JSONObject.
At the moment I am using json-lib.
This is what I have, but it throws an exception:
XMLSerializer xml = new XMLSerializer();
JSON json = xml.readFromFile("samples/sample7.json”); //line 507
System.out.println(json.toString(2));
The output is:
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
at net.sf.json.xml.XMLSerializer.readFromStream(XMLSerializer.java:386)
at net.sf.json.xml.XMLSerializer.readFromFile(XMLSerializer.java:370)
at corebus.test.deprecated.TestMain.main(TestMain.java:507)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…