How to parse json file as input in java4

75 Views Asked by At

I want to parse json file as input and my code is

public static void getjsonfile() {
    // TODO Auto-generated method stub
    JsonParser parser = new JsonParser();
    Object obj = null;
    try {
        obj = parser.parse(new FileReader("c:\\json\\jsonfile"));
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    JSONObject jsonObject = (JSONObject) obj;
    System.out.println("Json" + jsonObject);
}

I am using java 4. So JsonParser is not working... Is there any other way to get the JSON?

0

There are 0 best solutions below