for (int i = 0; i < fieldsToDelete.size(); i++) {
JsonNode fieldToDelete = fieldsToDelete.get(i);
if (!fieldToDelete.isTextual()) {
throw new JsonFormatException("fieldsToDelete should be an array of strings, encountered: " + fieldToDelete);
} else {
QName qname = QNameConverter.fromJson(fieldToDelete.getTextValue(), namespaces);
record.getFieldsToDelete().add(qname);
}
}
}
ObjectNode attributes = getObject(node, "attributes", null);
if (attributes != null) {
Iterator<Map.Entry<String, JsonNode>> it = attributes.getFields();
while(it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
record.getAttributes().put(entry.getKey(), entry.getValue().getTextValue());
}
}
Map<QName, MetadataBuilder> metadataBuilders = null;
ObjectNode metadata = getObject(node, "metadata", null);
if (metadata != null) {
metadataBuilders = new HashMap<QName, MetadataBuilder>();
Iterator<Map.Entry<String, JsonNode>> it = metadata.getFields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
MetadataBuilder builder = readMetadata(entry.getValue(), qname);
metadataBuilders.put(qname, builder);
}
}
ObjectNode metadataToDelete = getObject(node, "metadataToDelete", null);
if (metadataToDelete != null) {
if (metadataBuilders == null) {
metadataBuilders = new HashMap<QName, MetadataBuilder>();
}
Iterator<Map.Entry<String, JsonNode>> it = metadataToDelete.getFields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
QName qname = QNameConverter.fromJson(entry.getKey(), namespaces);
MetadataBuilder builder = readMetadataToDelete(entry.getValue(), metadataBuilders.get(qname), qname);
metadataBuilders.put(qname, builder);
}
}