0

I'm using Eclipse and I'm trying to follow along this tutorial:

https://code.google.com/p/json-simple/wiki/DecodingExamples#Example_2_-_Faster_way:_Reuse_instance_of_JSONParser

But I'm encountering some problems when using a JSONParser object. When I try to simply call:

    JSONParser parser = new JSONParser();
    Object obj = parser.parse(json_out);

I get an error saying: Unhandled exception of type ParseException.

But when I use a try statement I get:

    JSONParser parser = new JSONParser();
    try{    
        Object obj = parser.parse(json_out);
    }catch(ParseException e){
        e.printStackTrace();
    }


Unhandled exception type ParseException
Unreachable catch block for ParseException. This exception is never thrown from the try statement body

Can anybody help me with this?

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
eager2learn
  • 1,447
  • 4
  • 24
  • 47

1 Answers1

0

So according to this documentation the JSONParser class does not contain a parse() method.

You can use this as a possibility:

JSONArray arr = new JSONArray(content);

Then parse it using this:

JSONObject obj = arr.getJSONObject(i);
frankgreco
  • 1,426
  • 1
  • 18
  • 31