Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Filtering primitive JSON types (plain strings, numbers) #130

Open
max-mapper opened this issue Apr 26, 2017 · 1 comment
Open

Filtering primitive JSON types (plain strings, numbers) #130

max-mapper opened this issue Apr 26, 2017 · 1 comment

Comments

@max-mapper
Copy link
Collaborator

I use this in http://npmjs.org/jsonfilter which accepts any valid JSON as input, but this doesn't match anything in jsonfilter:

echo '"foo"' | jsonfilter "*"

I made a test case for it too:

var JSONStream = require('../')

var test = require('tape')

test ('primitive types', function (t) {
  var actual = []
  var stream = 

  JSONStream.parse('*')
    .on('data', function (v) { actual.push(v) })
    .on('end', function () {
      t.deepEqual(actual, ["foo"])
      t.end()
    })

  stream.write('"foo"')
  stream.end()
})

Is there a way to match strings and numbers and bools now or would it require a PR to either JSONStream or jsonparse?

@dominictarr
Copy link
Owner

The * matches the key not the value, I think the answer is yes, it would require a RP, unless an empty string works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants