1
14
15 package com.liferay.portlet.expando.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
21 import com.liferay.portlet.expando.model.ExpandoColumn;
22
23 import java.util.List;
24
25
41 public class ExpandoColumnJSONSerializer {
42 public static JSONObject toJSONObject(ExpandoColumn model) {
43 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
44
45 jsonObj.put("columnId", model.getColumnId());
46 jsonObj.put("companyId", model.getCompanyId());
47 jsonObj.put("tableId", model.getTableId());
48 jsonObj.put("name", model.getName());
49 jsonObj.put("type", model.getType());
50 jsonObj.put("defaultData", model.getDefaultData());
51 jsonObj.put("typeSettings", model.getTypeSettings());
52
53 return jsonObj;
54 }
55
56 public static JSONArray toJSONArray(
57 com.liferay.portlet.expando.model.ExpandoColumn[] models) {
58 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
59
60 for (ExpandoColumn model : models) {
61 jsonArray.put(toJSONObject(model));
62 }
63
64 return jsonArray;
65 }
66
67 public static JSONArray toJSONArray(
68 com.liferay.portlet.expando.model.ExpandoColumn[][] models) {
69 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
70
71 for (ExpandoColumn[] model : models) {
72 jsonArray.put(toJSONArray(model));
73 }
74
75 return jsonArray;
76 }
77
78 public static JSONArray toJSONArray(
79 List<com.liferay.portlet.expando.model.ExpandoColumn> models) {
80 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
81
82 for (ExpandoColumn model : models) {
83 jsonArray.put(toJSONObject(model));
84 }
85
86 return jsonArray;
87 }
88 }