I want to map my Input JSON with another JSON using mustache
.
My Input JSON is like:
{
"data": [
{ "catalogId": "1850", "productId": "ELEC004A"},
{ "catalogId": "1851", "productId": "PNG679"}
]
}
I want a template in which I could combine the mustache tags with my output json.
var template = JSON.stringify(
{
Product: [
{{#data}}
{
productId:'{{productId}}',
parentProductId:'{{catalogId}}'
}
{{/data}}
]
}
);
I tried this but using mustache tag with JSON are giving me errors.
I tried defining the template without using JSON.stringify
but no luck!
Have to use mustache only as it is the requirement, the actual input JSON is quite large and can't map it using the traditional way.