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.ClassName;
21
22 import java.util.List;
23
24
40 public class ClassNameJSONSerializer {
41 public static JSONObject toJSONObject(ClassName model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("classNameId", model.getClassNameId());
45 jsonObj.put("value", model.getValue());
46
47 return jsonObj;
48 }
49
50 public static JSONArray toJSONArray(
51 com.liferay.portal.model.ClassName[] models) {
52 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
53
54 for (ClassName model : models) {
55 jsonArray.put(toJSONObject(model));
56 }
57
58 return jsonArray;
59 }
60
61 public static JSONArray toJSONArray(
62 com.liferay.portal.model.ClassName[][] models) {
63 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
64
65 for (ClassName[] model : models) {
66 jsonArray.put(toJSONArray(model));
67 }
68
69 return jsonArray;
70 }
71
72 public static JSONArray toJSONArray(
73 List<com.liferay.portal.model.ClassName> models) {
74 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
75
76 for (ClassName model : models) {
77 jsonArray.put(toJSONObject(model));
78 }
79
80 return jsonArray;
81 }
82 }