4
I need to convert one ArrayList
of String
on a JSON.
I have a method in which I get a list of apps installed on the mobile device. This method returns me the data in a String Arraylist.
I was able to generate a JSON using JSONArray
but I couldn’t insert a tag inside Json, below is JSON using JSONArray
.
Json: ["com.br.package1", "com.br.package2", "com.br.package3"]
I need Json to look like this:
[{"name": "com.br.package1"},{"name": "com.br.package2"}, {"name":"com.br.package3"}]
Below is an excerpt of the code:
//Cria e inicializa ArrayList que contem os packages instalados no Aparelho
ArrayList<String> mPackages = new ArrayList<String>();
//Grava no ArrayList o retorno do método
mPackages = Util.buscaAppsInstalados(getBaseContext());
JSONArray jsonArray = new JSONArray(mPackages);
This "name" is fixed?
– Pablo Almeida
Hello Pablo yes is fixed
– dnsfirmino