Source:
<code>public JSONObject toJSON() { JSONObject ret = new JSONObject(); JSONHelper.putValue(ret, "fileIdentifier", fileIdentifier); JSONHelper.putValue(ret, "metadataLanguage", metadataLanguage); JSONHelper.putValue(ret, "metadataCharacterSet", metadataCharacterSet); JSONHelper.putValue(ret, "scopeCodes", scopeCodes); JSONHelper.putValue(ret, "referenceSystems", referenceSystems); JSONArray arr = new JSONArray(); for (ResponsibleParty responsibleParty : metadataResponsibleParties) { arr.put(responsibleParty.toJSON()); } JSONHelper.putValue(ret, "metadataResponsibleParties", arr); JSONHelper.putValue(ret, "metadataDateStamp", metadataDateStamp); JSONHelper.putValue(ret, "metadataStandardName", metadataStandardName); JSONHelper.putValue(ret, "metadataStandardVersion", metadataStandardVersion); JSONHelper.putValue(ret, "metadataURL", metadataURL); arr = new JSONArray(); for (Identification identification : identifications) { arr.put(identification.toJSON()); } JSONHelper.putValue(ret, "identifications", arr); arr = new JSONArray(); for (DistributionFormat distributionFormat : distributionFormats) { arr.put(distributionFormat.toJSON()); } JSONHelper.putValue(ret, "distributionFormats", arr); arr = new JSONArray(); for (OnlineResource onlineResource : onlineResources) { arr.put(onlineResource.toJSON()); } JSONHelper.putValue(ret, "onlineResources", arr); ObjectMapper mapper = new ObjectMapper(); <START> String json = ""; <END> try { arr = new JSONArray(); for (DataQuality dqNode: dataQualityObject.getDataQualities()){ json = mapper.writeValueAsString(dqNode); arr.put(JSONHelper.createJSONObject(json)); } } catch (Exception e) { } JSONHelper.putValue(ret, "dataQualities", arr); arr = new JSONArray(); for (String lineage : dataQualityObject.getLineageStatements()){ arr.put(lineage); } JSONHelper.putValue(ret, "lineageStatements", arr); return ret; }</code><technical_language>is this of loop</technical_language>

Target:
public JSONObject toJSON() { JSONObject ret = new JSONObject(); JSONHelper.putValue(ret, "fileIdentifier", fileIdentifier); JSONHelper.putValue(ret, "metadataLanguage", metadataLanguage); JSONHelper.putValue(ret, "metadataCharacterSet", metadataCharacterSet); JSONHelper.putValue(ret, "scopeCodes", scopeCodes); JSONHelper.putValue(ret, "referenceSystems", referenceSystems); JSONArray arr = new JSONArray(); for (ResponsibleParty responsibleParty : metadataResponsibleParties) { arr.put(responsibleParty.toJSON()); } JSONHelper.putValue(ret, "metadataResponsibleParties", arr); try { JSONHelper.putValue(ret, "metadataDateStamp", metadataDateStamp.format(DATE_TIME_FORMAT)); } catch (Exception e) { } JSONHelper.putValue(ret, "metadataStandardName", metadataStandardName); JSONHelper.putValue(ret, "metadataStandardVersion", metadataStandardVersion); JSONHelper.putValue(ret, "metadataURL", metadataURL); arr = new JSONArray(); for (Identification identification : identifications) { arr.put(identification.toJSON()); } JSONHelper.putValue(ret, "identifications", arr); arr = new JSONArray(); for (DistributionFormat distributionFormat : distributionFormats) { arr.put(distributionFormat.toJSON()); } JSONHelper.putValue(ret, "distributionFormats", arr); arr = new JSONArray(); for (OnlineResource onlineResource : onlineResources) { arr.put(onlineResource.toJSON()); } JSONHelper.putValue(ret, "onlineResources", arr); try { arr = new JSONArray(); for (DataQuality dqNode: dataQualityObject.getDataQualities()){ String json = mapper.writeValueAsString(dqNode); arr.put(JSONHelper.createJSONObject(json)); } } catch (Exception e) { } JSONHelper.putValue(ret, "dataQualities", arr); arr = new JSONArray(dataQualityObject.getLineageStatements()); JSONHelper.putValue(ret, "lineageStatements", arr); return ret; }