1
14
15 package com.liferay.portlet.softwarecatalog.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.softwarecatalog.model.SCLicense;
22
23 import java.util.List;
24
25
41 public class SCLicenseJSONSerializer {
42 public static JSONObject toJSONObject(SCLicense model) {
43 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
44
45 jsonObj.put("licenseId", model.getLicenseId());
46 jsonObj.put("name", model.getName());
47 jsonObj.put("url", model.getUrl());
48 jsonObj.put("openSource", model.getOpenSource());
49 jsonObj.put("active", model.getActive());
50 jsonObj.put("recommended", model.getRecommended());
51
52 return jsonObj;
53 }
54
55 public static JSONArray toJSONArray(
56 com.liferay.portlet.softwarecatalog.model.SCLicense[] models) {
57 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
58
59 for (SCLicense model : models) {
60 jsonArray.put(toJSONObject(model));
61 }
62
63 return jsonArray;
64 }
65
66 public static JSONArray toJSONArray(
67 com.liferay.portlet.softwarecatalog.model.SCLicense[][] models) {
68 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
69
70 for (SCLicense[] model : models) {
71 jsonArray.put(toJSONArray(model));
72 }
73
74 return jsonArray;
75 }
76
77 public static JSONArray toJSONArray(
78 List<com.liferay.portlet.softwarecatalog.model.SCLicense> models) {
79 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
80
81 for (SCLicense model : models) {
82 jsonArray.put(toJSONObject(model));
83 }
84
85 return jsonArray;
86 }
87 }