Currently I am receiving a response like this from my API:
[{"$id":"1","accommodation_type":"apartment","max_people":2},{"$id":"2","accommodation_type":"lodge","max_people":5}]
I would like to format it so that the output removes all the unnecessary punctuation so that it looks more like this whilst also placing it into an Array.
id, 1, accommodation_type, apartment, max_people, 2, id, 2, accommodation_type, lodge, max_people 5
OR
1, apartment, 2, ,2, lodge, 5
Currently I have tried:
String temp[]= AccommodationTypesStr.split(":|\\,|\\}"); // Where AccommodationTypesStr is the input json string
However between each row of data it leaves a empty space as a element in the array so its like:
id, 1, accomodation_type, apartment, max_people, 2, ,id, 2, accommodation_type, lodge, max_people 5
Whilst also still having some brackets in the response.
I've messed around with JSON Object and Array but had no luck at all so was wondering if I could do it by formatting it myself.