js.map_metadata_fields.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of exporter-transformer Show documentation
Show all versions of exporter-transformer Show documentation
Dataverse configuration-driven transformer exporter using either a JSON-Transformer, JavaScript or Python.
mapSubField = function (subField, multiple) {
if (typeof subField === 'string') {
return subField
}
var resArray = new List()
subField.forEach(function (value) {
if (value.keySet) {
var mappedSubField = {}
value.keySet().forEach(function (key) {
mappedSubField[key] = mapSubField(value.get(key).value, value.get(key).multiple)
})
resArray.add(mappedSubField)
} else {
resArray.add(value)
}
})
return multiple ? resArray : resArray[0]
}
res = {}
x.keySet().stream().forEach(function (key) {
res[key] = {}
x[key].fields.stream().forEach(function (field) {
res[key][field.typeName] = mapSubField(field.value, field.multiple)
})
})