1
22
23 package com.liferay.portal.service.http;
24
25 import com.liferay.portal.kernel.json.JSONArray;
26 import com.liferay.portal.kernel.json.JSONFactoryUtil;
27 import com.liferay.portal.kernel.json.JSONObject;
28 import com.liferay.portal.model.Region;
29
30 import java.util.List;
31
32
48 public class RegionJSONSerializer {
49 public static JSONObject toJSONObject(Region model) {
50 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
51
52 jsonObj.put("regionId", model.getRegionId());
53 jsonObj.put("countryId", model.getCountryId());
54 jsonObj.put("regionCode", model.getRegionCode());
55 jsonObj.put("name", model.getName());
56 jsonObj.put("active", model.getActive());
57
58 return jsonObj;
59 }
60
61 public static JSONArray toJSONArray(
62 com.liferay.portal.model.Region[] models) {
63 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
64
65 for (Region model : models) {
66 jsonArray.put(toJSONObject(model));
67 }
68
69 return jsonArray;
70 }
71
72 public static JSONArray toJSONArray(
73 com.liferay.portal.model.Region[][] models) {
74 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
75
76 for (Region[] model : models) {
77 jsonArray.put(toJSONArray(model));
78 }
79
80 return jsonArray;
81 }
82
83 public static JSONArray toJSONArray(
84 List<com.liferay.portal.model.Region> models) {
85 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
86
87 for (Region model : models) {
88 jsonArray.put(toJSONObject(model));
89 }
90
91 return jsonArray;
92 }
93 }