0

I want to split the value 08:41:19 from below json response. How to split the value?

{
  "parameters": [
    {
      "name": "CurrentLocalTime",
      "value": "2019-05-29 08:41:19",
      "dataType": 4,
      "parameterCount": 1,
      "message": "Success"
    }
  ],
  "statusCode": 200
}
Jordan
  • 2,273
  • 9
  • 16
user1984
  • 13
  • 2
  • 11
  • what have you tried so far? show us your code. this will help you. https://stackoverflow.com/questions/2591098/how-to-parse-json-in-java – Madplay May 29 '19 at 13:50
  • Start with using a JSON library to extract the string `"2019-05-29 08:41:19"`. Then split() on the space. – kumesana May 29 '19 at 13:50

1 Answers1

0

Try this,

 JSONArray jSONArray = inputJSON.getJSONArray("parameters");
 int length = jSONArray.length();
  for (int i = 0; i < length; i++) {
        JSONObject jSONObject= jSONArray.getJSONObject(i);
        System.out.println(jSONObject.get("value").split("\\s")[1]);
    }
Srinivasan Sekar
  • 2,049
  • 13
  • 22