1
19
20 package com.liferay.portlet.softwarecatalog.service.http;
21
22 import com.liferay.portal.kernel.json.JSONArray;
23 import com.liferay.portal.kernel.json.JSONFactoryUtil;
24 import com.liferay.portal.kernel.json.JSONObject;
25
26 import com.liferay.portlet.softwarecatalog.model.SCLicense;
27
28 import java.util.List;
29
30
49 public class SCLicenseJSONSerializer {
50 public static JSONObject toJSONObject(SCLicense model) {
51 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
52
53 jsonObj.put("licenseId", model.getLicenseId());
54 jsonObj.put("name", model.getName());
55 jsonObj.put("url", model.getUrl());
56 jsonObj.put("openSource", model.getOpenSource());
57 jsonObj.put("active", model.getActive());
58 jsonObj.put("recommended", model.getRecommended());
59
60 return jsonObj;
61 }
62
63 public static JSONArray toJSONArray(
64 com.liferay.portlet.softwarecatalog.model.SCLicense[] models) {
65 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
66
67 for (SCLicense model : models) {
68 jsonArray.put(toJSONObject(model));
69 }
70
71 return jsonArray;
72 }
73
74 public static JSONArray toJSONArray(
75 com.liferay.portlet.softwarecatalog.model.SCLicense[][] models) {
76 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
77
78 for (SCLicense[] model : models) {
79 jsonArray.put(toJSONArray(model));
80 }
81
82 return jsonArray;
83 }
84
85 public static JSONArray toJSONArray(
86 List<com.liferay.portlet.softwarecatalog.model.SCLicense> models) {
87 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
88
89 for (SCLicense model : models) {
90 jsonArray.put(toJSONObject(model));
91 }
92
93 return jsonArray;
94 }
95 }