json icon indicating copy to clipboard operation
json copied to clipboard

Would like 'this' set for conditional processing on arrays

Open jclulow opened this issue 11 years ago • 2 comments

I would like to be able to act on each member of an array, in turn, as part of conditional/exec processing. It would be neat if each member of an array could be broken out, inserted into the context as this, and the resulting filtered/modified array reconstituted.

For example, with a dataset like this:

[
  "some text",
  "some more text",
  "a third string"
]

It would be cool to be able to say:

json -f input_array.json -ga -c "this.match(/some/)"

And receive the output:

[
  "some text",
  "some more text"
]

jclulow avatar Apr 30 '13 22:04 jclulow

@jclulow :+1: Funny, I was just looking for similar functionality.

szaydel avatar Apr 30 '13 22:04 szaydel

this can be easily done with underscore-cli just in case anyone is looking for a solution now.

boxxxie avatar May 01 '13 15:05 boxxxie