I have the following data in Json how could I retrieve data from this file
{\"first_name\":\"immi\",\"last_name\":\"Ahmad\",\"contact_no\":\"0333333\",\"dob\":\"
if your responce is to big than @tiny sunlight method not work
You cant do like
JSONObject userinfo= new JSONObject(result);
userinfo.getString("first_name");
JSONObject someObject = userinfo.getJsonObject("somthing")
JSONObject somthingElse = someObject.getJsonObject("somthingElse")
That become too hectic and nearly wasting your time
So BEST ANSWER is Gson Liabrary
Gson gson = new GsonBuilder().create();
Movie movie = gson.fromJson(response, Movie.class);
hear movie is class that you map from json - show in below link
you can do vise-varsa also
Gson gson = new GsonBuilder().create();
Responce mResponce = gson.fromJson(jsonStr , Responce .class);
String mName =mResponce.result.name;
https://stackoverflow.com/a/41218155/4741746
Hope you will understand which answer is best
That's your all the content of json file?
You should create a class to store the information of every json object.
example you create PersonalInformation class have have instances "firstname", "lastname", "gender"...
Then we use a for-loop statement to read all information.
Hope this help!
JSONObject userinfo= new JSONObject(result);
userinfo.getString("first_name");
Try to Use Gson
to simplify it!