final ObjectAdapter fieldValue = association.get(object);
final String fieldName = association.getId();
if (fieldValue == null) {
data.put(fieldName, (Object) null);
} else if (association.getSpecification().isEncodeable()) {
final EncodableFacet encodeableFacet = fieldValue.getSpecification().getFacet(EncodableFacet.class);
data.put(fieldName, encodeableFacet.toEncodedString(fieldValue));
} else if (association instanceof OneToManyAssociation) {
final List<JSONObject> collection = new ArrayList<JSONObject>();
final CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
for (final ObjectAdapter element : facet.iterable(fieldValue)) {
collection.add(encodeTransientData(element, savedObject));