Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "fullName": "a",
- "password": "a",
- "roles": [
- {
- "role_id": "dilbert"
- },
- {
- "roleId": "admin"
- }
- ]
- }
- ]
- public static User fromJson(JSONObject json) throws JSONException {
- User u = new User();
- u.setFullName(json.getString("fullName"));
- u.setPassword(json.getString("password"));
- JSONArray array = json.getJSONArray("roles");
- for(int i=0; i < array.length(); i++){
- JSONObject o = array.getJSONObject(i);
- Role r = Role.fromJson(o);
- }
- return u;
- }
- public static Role fromJson(JSONObject json) throws JSONException {
- Role r = new Role();
- r.setRole_id(json.getString("roles"));
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement