Inist-CNRS / node-jbj

Like XSL/XML but for JSON.
http://Inist-CNRS.github.io/jbj-playground/
13 stars 3 forks source link

How to ? #20

Open kerphi opened 8 years ago

kerphi commented 8 years ago

I have this data:

{ keyAsString: '7051', key: 160340860800000, docCount: 1 }

I tried this stylesheet:

      {
        "$year": {
          "get" : "keyAsString",
          "cast": "number"
        },
        "$nbDocument": {
          "get" : "docCount",
        },
      }

I got this result:

{ keyAsString: '9167',
  key: 227115360000000,
  docCount: 1,
  year: 9167,
  nbDocument: 1 }

I'd like to have this result instead:

{ year: 9167,
  nbDocument: 1 }

Thanks in advance for any help.

parmentf commented 8 years ago

Use mask:

{
  "$year": {
    "get" : "keyAsString",
    "cast": "number"
  },
  "$nbDocument": {
    "get" : "docCount",
  },
  "mask": "year,nbDocument"
}
kerphi commented 8 years ago

Thank you !

On Thu, Mar 10, 2016 at 9:45 AM, François Parmentier < notifications@github.com> wrote:

Use mask https://github.com/Inist-CNRS/node-jbj#mask:

{ "$year": { "get" : "keyAsString", "cast": "number" }, "$nbDocument": { "get" : "docCount", }, "mask": "year,nbDocument" }

— Reply to this email directly or view it on GitHub https://github.com/Inist-CNRS/node-jbj/issues/20#issuecomment-194738371.