Skip to content

Mapper

Quickly transform your data

A mapping is itself a document, pairing each target location with the source that fills it:

/citation/title: /title
/citation/doi:
source: /ids
find:
eq: { idType: doi }
pointer: /value
/citation/authors:
source: /contributors
each:
/family: /surname

Given an input:

{
"title": "On Mapping",
"ids": [
{ "idType": "issn", "value": "2049-3630" },
{ "idType": "doi", "value": "10.1000/xyz123" }
],
"contributors": [{ "surname": "Hopper" }, { "surname": "Noether" }]
}

applying the mapping:

import Mapper from '@christiansmith/mapper-js'
const mapper = new Mapper({}, { initializers: {}, transformers: {}, plugins: {} })
const { valid, errors, ...result } = await mapper.map(mapping, input)

produces:

{
"citation": {
"title": "On Mapping",
"doi": "10.1000/xyz123",
"authors": [{ "family": "Hopper" }, { "family": "Noether" }]
}
}

Every example in these docs, including this one, is executed against the published implementation as part of the site’s test suite.

One language, three published pieces. Mappings written for the engine run unchanged behind the plugin and the server: