Hi all I am getting the below response when execute a REST request.
["A103388","R101858","R5575"]
but I need the values between the braces []. I tried using the split() and replace() but not able to achieve.
No Need to SPLIT . If you playing with JSONObject
JSONObject object = new JSONObject(response_message); //["A103388","R101858","R5575"]
for(int i = 0; i<object.length() ; i++)
{
String getValue= object.get(i);
}
Another Way
String getValue="your_respose";
String [] getSplit=getValue.split(",");
for(int i = 0; i < getSplit.length; i++)
{
System.out.println("Amiyo"+getSplit[i]);
}
In order to get the individual values, you can use the following code:
String input = "[\"A103388\",\"R101858\",\"R5575\"]"
String[] parsedInput = input.replaceAll("[\[\]]", "").split(",")
This code will replace all brackets with nothing, essentially removing it (input.replaceAll("[\[\]]", "")), after which it is split on the comma (.split(",")). This results in a String array, which has each of the requested elements as elements.