I am currently receiving a JSON Object From the Server side of my application, the result is this
{"tags":"[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]"}
But then I don't really need the "tags" and the double quotes in the result.
So what I want is an array representation of that JSON object
therefore how would I convert this
{"tags":"[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]"}
to this
[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]
Here's the loop that creates the array
String k = "[";
List<Tag> tg = audioTaggingService.findTagsByName(q);
for(int i = 0; i<audioTaggingService.findTagsByName(q).size();i++){
Tag t = tg.get(i);
if(i == (tg.size() - 1)){
k+="{value: "+t.getId()+",label:'"+t.getName()+"'}";
}else{
k+="{value: "+t.getId()+",label:'"+t.getName()+"'}";
}
}
k+="]";
The result of the code above is this
[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]