### Question:
PhysicalWebCollection { public JSONObject jsonSerialize() { JSONObject jsonObject = new JSONObject(); JSONArray urlDevices = new JSONArray(); for (UrlDevice urlDevice : mDeviceIdToUrlDeviceMap.values()) { urlDevices.put(urlDevice.jsonSerialize()); } jsonObject.put(DEVICES_KEY, urlDevices); JSONArray metadata = new JSONArray(); for (PwsResult pwsResult : mBroadcastUrlToPwsResultMap.values()) { metadata.put(pwsResult.jsonSerialize()); } jsonObject.put(METADATA_KEY, metadata); JSONObject iconMap = new JSONObject(); for (String iconUrl : mIconUrlToIconMap.keySet()) { iconMap.put(iconUrl, new String(Base64.encodeBase64(getIcon(iconUrl)), Charset.forName("UTF-8"))); } jsonObject.put(ICON_MAP_KEY, iconMap); jsonObject.put(SCHEMA_VERSION_KEY, SCHEMA_VERSION); return jsonObject; } PhysicalWebCollection(); boolean addUrlDevice(UrlDevice urlDevice); void removeUrlDevice(UrlDevice urlDevice); void addMetadata(PwsResult pwsResult); void addIcon(String url, byte[] icon); void clear(); byte[] getIcon(String url); UrlDevice getUrlDeviceById(String id); PwsResult getMetadataByBroadcastUrl(String broadcastUrl); List<UrlDevice> getUrlDevices(); JSONObject jsonSerialize(); static PhysicalWebCollection jsonDeserialize(JSONObject jsonObject); List<PwPair> getPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getGroupedPwPairsSortedByRank(Comparator<PwPair> comparator); List<PwPair> getPwPairs(); PwPair getTopRankedPwPairByGroupId(String groupId, Comparator<PwPair> comparator); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion); void setPwsEndpoint(String pwsEndpoint, int pwsApiVersion, String pwsApiKey); void fetchPwsResults(final PwsResultCallback pwsResultCallback,
                              final PwsResultIconCallback pwsResultIconCallback); void cancelAllRequests();  }### Answer:
@Test public void jsonSerializeWorks() { JSONAssert.assertEquals(physicalWebCollection1.jsonSerialize(), jsonObject1, true); }