0

Let say I have JSON file and I want to retrieve only pets from it. Any code to retrieve them would be appreciated.

JSON file.

{
  "age":100,
  "name":"Hubble",
  "pets":["Hunde","Katze","Fisch"]
}

So, I found this code to parse JSON to String. At the end it returns string,but the point is that I can't get what String is that. It is all data inside my JSON file or any other?

 public static String jsonToStringFromAssetFolder(String fileName,Context context) throws IOException {
        AssetManager manager = context.getAssets();
        InputStream file = manager.open(fileName);

        byte[] data = new byte[file.available()];
        file.read(data);
        file.close();
        return new String(data);
    }
Farid
  • 2,317
  • 1
  • 20
  • 34

0 Answers0