Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Node object-mapper Array

node v8.17.0
version: master
endpointsharetweet
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);
Loading…

no comments

    sign in to comment