See an example here: http://docs.marklogic.com/guide/mlcp/import#id_26044
The original input document is expected to take the following form:
{ uri: string, value: node }
This is also the expected output form for each document. You will also want your return to be of type document-node, since you want mlcp to split it and swallow it as JSON documents.
So your custom .sjs conversion module will look something like this.
function splitFeatures(doc) { const features = doc.value.toObject().features; return xdmp.arrayValues( features.map(function(feature) { return { uri: '/path/itemhere-' + xdmp.random() + '.json', value: xdmp.toJSON(feature) } }) ); } exports.transform = splitFeatures;
Aside, this is a useful resource when working with JSON in MarkLogic .
source share