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