Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is the JSON that my API return:
- {
- "success": true,
- "message": "User successfully retrieved",
- "data": {
- "id": "1",
- "username": "admin",
- "password": null,
- "created": "2018-04-15 11:53:28",
- "modified": "2018-04-15 11:53:28",
- "grade": "4",
- "gradename": "Administrator",
- "department": "5",
- "departmentname": "Operations"
- }
- }
- The data part is what i need to parse. I beleive that the data part is another json object. How can I access it from Android?
- This is the code I have used in the past:
- managerSecurityApi.login (etUsername.getText ().toString (), etPassword.getText ().toString (), new Callback<ArrayList<ObjectUser>>() {
- @Override
- public void onResponse (@NonNull Call<ArrayList<ObjectUser>> call, @NonNull Response<ArrayList<ObjectUser>> response) {
- ArrayList<ObjectUser> JSONList = response.body();
- for (int i = 0; i < Objects.requireNonNull(JSONList).size(); i++) {
- objectUser.add(new ObjectUser (
- JSONList.get(i).getId(),
- JSONList.get(i).getUsername(),
- JSONList.get(i).getGrade(),
- JSONList.get(i).getGradename(),
- JSONList.get(i).getDepartment(),
- JSONList.get(i).getDepartmentname()
- ));
- But the information I need to access is in the data object in the JSON response. I am not sure how to access it.
Add Comment
Please, Sign In to add comment