Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry How to read child node from root node0 in json using java

    library used com.google.gson

    try{
    JsonReader reader=new JsonReader(new FileReader("E:/nagesh workspace/practice/WebContent/jsnf/newProject.json"));

    reader.beginObject();
    while(reader.hasNext())
    {

    String name = reader.nextName();
    System.out.println(name);
    if("Student".equals(name))
    {
    System.out.println("student list count = "+name.);
    }
    else if (name.equals("Name")) {
    System.out.println(reader.nextString());
    } else if (name.equals("Address")) {
    System.out.println(reader.nextString());
    }
    else
    {
    reader.skipValue();
    }
    }

    reader.endObject();
    reader.close();
    }
    catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }

    this is my code..
    plzzz help me if anyone know this.....

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    This is a Javascript forum, but your question is about Java

    Wrong forum!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •