简体   繁体   中英

Json Parsing for Login Api

I want to pasrse the json login Api..where the login page contains Pinnumber and password. .. i want to login with these details and then want to go to registration page.. with the details from the Api.. can anyone help me in this

thanks in advance

Please try this code below:

String response ="{\"0\":{\"SessionId\":\"zDQKMvGMWD4e9960e376988\"},\"memberdetails\":{\"Ident\":8,\"PinNumber\":\"justpinme1\",\"Password\":\"justpinme1\",\"EmailAddress\":\"justpinme1@gmail.com\",\"FirstName\":\"test1\",\"LastName\":123,\"Birthdate\":19860909,\"Gender\":\"female\",\"Country\":\"india\",\"PhoneNumber\":2147483647,\"PhotoThumb\":\"\",\"PhotoOriginal\":\"\",\"RegisteredDate\":\"2011-09-06 09:18:31\",\"RegisteredIp\":\"122.165.76.30\",\"RegisteredDeviceId\":22,\"LastSessionId\":\"hbS4JV9DNv4e99600c38390\",\"Status\":\"Active\",\"SessionId\":\"zDQKMvGMWD4e9960e376988\"}}";//Assign the response that are getting on the login api
        try {
            JSONObject jsonObject   =   new JSONObject(response);
            JSONObject forSessionId = jsonObject.getJSONObject("0");
            String SessionId = forSessionId.getString("SessionId");
            System.out.println("SessionId="+SessionId);
            JSONObject memberdetails    =    jsonObject.getJSONObject("memberdetails");
            System.out.println("Ident="+memberdetails.getString("Ident"));
            System.out.println("PinNumber="+memberdetails.getString("PinNumber"));
            System.out.println("Password="+memberdetails.getString("Password"));
            System.out.println("EmailAddress="+memberdetails.getString("EmailAddress"));
            System.out.println("FirstName="+memberdetails.getString("FirstName"));

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM