-1

JSONObject jsonObj = new JSONObject();

 jsonObj.put("name","raja");

Declare the jsonobject var(jsonObj) and gave value("name","raja") using above code.

 System.out.println(jsonObj.name);

Just print the name but it shows the error.

Carl Edwards
  • 13,826
  • 11
  • 57
  • 119
raja
  • 15
  • 7

1 Answers1

1

try this:

System.out.println(jsonObj.getString("name"));
  • System.out.println(jsonObj.get("name")); it works well. Thank u @Abhay Jain – raja Jun 16 '18 at 13:08
  • yes it gets you the object but in your case you know the type of your object that is a string –  Jun 16 '18 at 13:10
  • how to exit the loop while running using angular js. – raja Jun 18 '18 at 09:43
  • this question you have to ask it in the tag angular not here. to exit a loop is simple add a boolean initialises the false and do your treatment when you want to exit changes this boolean has true (it's for a while loop) please specify which loop you use –  Jun 18 '18 at 09:50