-1

I want to get the value of the message property in Java:

{ "responseStatus": { "message": "Success" } }

I did this:

lJsonObj.getString("??")
sdabet
  • 18,360
  • 11
  • 89
  • 158
Hanumant
  • 1
  • 3
  • possible duplicate of [JSONObject - How to get a value ?](http://stackoverflow.com/questions/7451600/jsonobject-how-to-get-a-value) – jwpfox Aug 27 '15 at 12:29

1 Answers1

0

You can get a nested json object with this:

JSONObject nestedJsonObject = rootJsonObject.getJSONObject("responseStatus");

You can get a string from a json object with this:

String message = nestedJsonObject.getString("message");
sembozdemir
  • 4,137
  • 3
  • 21
  • 30
  • 1
    Good answers *explain* as well as provide code. Consider updating your answer to include an explanation about how this code works and why it is the best option. – Ajean Aug 28 '15 at 00:50
  • I want to use slurper parsing. Where I am passing json Xpath from a variable. like def JsonXpath = 'error.errorDetails.errorText' slurper = new JsonSlurper() json = slurper.parseText(responseJsonGP) log.info "json ####" +json resValue = json.(aGlobalProperties[i].toObject) – Hanumant Feb 23 '18 at 14:00