001
014
015 package com.liferay.portal.service.http;
016
017 import com.liferay.portal.kernel.json.JSONArray;
018 import com.liferay.portal.kernel.json.JSONFactoryUtil;
019 import com.liferay.portal.kernel.json.JSONObject;
020 import com.liferay.portal.model.Role;
021
022 import java.util.List;
023
024
028 public class RoleJSONSerializer {
029 public static JSONObject toJSONObject(Role model) {
030 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
031
032 jsonObj.put("roleId", model.getRoleId());
033 jsonObj.put("companyId", model.getCompanyId());
034 jsonObj.put("classNameId", model.getClassNameId());
035 jsonObj.put("classPK", model.getClassPK());
036 jsonObj.put("name", model.getName());
037 jsonObj.put("title", model.getTitle());
038 jsonObj.put("description", model.getDescription());
039 jsonObj.put("type", model.getType());
040 jsonObj.put("subtype", model.getSubtype());
041
042 return jsonObj;
043 }
044
045 public static JSONArray toJSONArray(com.liferay.portal.model.Role[] models) {
046 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
047
048 for (Role model : models) {
049 jsonArray.put(toJSONObject(model));
050 }
051
052 return jsonArray;
053 }
054
055 public static JSONArray toJSONArray(
056 com.liferay.portal.model.Role[][] models) {
057 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
058
059 for (Role[] model : models) {
060 jsonArray.put(toJSONArray(model));
061 }
062
063 return jsonArray;
064 }
065
066 public static JSONArray toJSONArray(
067 List<com.liferay.portal.model.Role> models) {
068 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
069
070 for (Role model : models) {
071 jsonArray.put(toJSONObject(model));
072 }
073
074 return jsonArray;
075 }
076 }