String mensao = "[\"brega_falcao\",\"SamiPietikainen\",\"TecRahul\",\"gpantuza\",\"mkyong\",\"mkyong\",\"YouTube\"]";
Mensao is the JSONArray that I want to convert.
I tried this but it did not work:
//Retiro o '[' do inicio e do fim ']' do array json
String modificada = mensao.substring(1, mensao.length() - 1);
List<String> lista = Arrays.asList(modificada);
for (int i = 0; i < lista.size(); i++) {
System.out.println(i + " " + lista.get(i));
}
The problem is that it prints a big string and does not create an array of strings ... (that's what I sent the code to do, ma is not what we want ...)
Exit
0 "brega_falcao","SamiPietikainen","TecRahul","gpantuza","mkyong","mkyong","YouTube"
While this is what you want:
0 brega_falcao
1 SamiPietikainen
2 TecRahul
3 gpantuza
4 mkyong
5 mkyong
6 YouTube