This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
var objectMapper = require("object-mapper")
var orig = {
foo: [
{"name": "a", "things": ["a1", "a2"]},
{"name": "b", "things": ["b1", "b2"]}
]
}
//BAD
var badMap = {
"foo[].name": "bar[].label",
"foo[].things[]": "bar[].values[]"
};
// GOOD
var goodMap = {
"foo[].name": "bar[].label",
"foo[].things[]": "bar[].values" // Note lack of [] on values
};
var badOb = objectMapper(orig, badMap);
console.log(badOb);
var goodOb = objectMapper(orig, goodMap);
console.log(goodOb);