How Can I parse a JSON ARRAY to get the data without the [] and \"\"
here is the json
\"formattedAddress\": [
\"23, Damansara - Puchong Hwy (Bandar
Use JSONArray#join()
to join the elements. Check out the JSONArray docs for more info.
poi.setFormattedAddress(
jsonArray.getJSONObject(i).getJSONObject("location")
.getJSONArray("formattedAddress").join(", ")); // passing ", " as the separator
It's unclear if the quotations are part of your input JSON string. If they show up in your join, you can easily remove them with the String#replace()
method.
System.out.println(jsonArray.join(", ").replace("\"", ""));