1
14
15 package com.liferay.portal.service.http;
16
17 import com.liferay.portal.kernel.json.JSONArray;
18 import com.liferay.portal.kernel.json.JSONFactoryUtil;
19 import com.liferay.portal.kernel.json.JSONObject;
20 import com.liferay.portal.model.Role;
21
22 import java.util.List;
23
24
40 public class RoleJSONSerializer {
41 public static JSONObject toJSONObject(Role model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("roleId", model.getRoleId());
45 jsonObj.put("companyId", model.getCompanyId());
46 jsonObj.put("classNameId", model.getClassNameId());
47 jsonObj.put("classPK", model.getClassPK());
48 jsonObj.put("name", model.getName());
49 jsonObj.put("title", model.getTitle());
50 jsonObj.put("description", model.getDescription());
51 jsonObj.put("type", model.getType());
52 jsonObj.put("subtype", model.getSubtype());
53
54 return jsonObj;
55 }
56
57 public static JSONArray toJSONArray(com.liferay.portal.model.Role[] models) {
58 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
59
60 for (Role model : models) {
61 jsonArray.put(toJSONObject(model));
62 }
63
64 return jsonArray;
65 }
66
67 public static JSONArray toJSONArray(
68 com.liferay.portal.model.Role[][] models) {
69 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
70
71 for (Role[] model : models) {
72 jsonArray.put(toJSONArray(model));
73 }
74
75 return jsonArray;
76 }
77
78 public static JSONArray toJSONArray(
79 List<com.liferay.portal.model.Role> models) {
80 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
81
82 for (Role model : models) {
83 jsonArray.put(toJSONObject(model));
84 }
85
86 return jsonArray;
87 }
88 }