Start a Project

How to create a JSONArray from a json file

Hello Everyone,

This time while working on creating a list for the recycler view, i tried loading it from a json file which i downloaded from internet.

Approach :

  1. Place your json file in your Assests folder.
  2. Create a string and start adding the contents of your json file into this string.
  3. use this string as argument while declaraing your JSONArray.

See, its really simple.

Let me give you example on how to code this approach and get it working.

Now the Function loadJSONFromAsset();

That’s it !

Now you have got your JSONArray and you can use it simply as per your requirements.

Keep coding and keep sharing. : )

Exit mobile version