I'm trying to parse this stock info at:
http://www.google.com/finance/info?client=ig&q=csco
that's in JSON format to a map, essentially following this tutorial I saw using the quick-json jar but it keeps giving me an exception and I can't figure out why. Here's the code, any help is greatly appreciated
Tutorial link: https://code.google.com/p/quick-json/
public static void main(String args[]) throws IOException
{
String value="";
URL uri = new URL("http://www.google.com/finance/info?client=ig&q=csco");
BufferedReader input = new BufferedReader(new InputStreamReader(uri.openStream(), "UTF-8"));
while(input.readLine()!=null)
{
value+=input.readLine();
}
JsonParserFactory factory = JsonParserFactory.getInstance();
JSONParser parse = factory.newJsonParser();
Map jsonData =parse.parseJson(value);
System.out.println((String)jsonData.get("e"));
}
Here's the exception I get:
Exception in thread "main" com.json.exceptions.JSONParsingException: @Key-Heirarchy::root[0]/ @Key:: COMMA or ] is expected. but found :...@Position::5
at com.json.utils.JSONUtility.handleFailure(JSONUtility.java:124)
at com.json.parsers.JSONParser.stringLiteralTemplate(JSONParser.java:574)
at com.json.parsers.JSONParser.nonValidatingValueTemplate(JSONParser.java:698)
at com.json.parsers.JSONParser.jsonArrayTemplate(JSONParser.java:454)
at com.json.parsers.JSONParser.parseJson(JSONParser.java:170)
at parser.Scratch.main(Scratch.java:27)
EDIT: I also tried Map jsonData =parse.parseJson(value.substring(3) to start at [ but it still gives me an error
//
is not parsable here