0

I have JSON object:

{
  "type": "...",
  "start": 0,
  "end": 93,
  "items": [
    {
      "type": "...",
      "start": 0,
      "end": 93,
      "more": {
        "type": "...",
        "start": 0,
        "__FOO__": true,
        "end": 93,

I want to get __FOO__ property from that object using json-query.

The problem is __FOO__ can be anywhere in the object. I mean deep inside or at the root. also the object structure can be change (array may be object or even not exist).

So I tried to get this property using this syntax but it doesn't work. What is the syntax that can find me __FOO__?

const data = require("./data.json");

const jsonQuery = require("json-query");

const x = jsonQuery("[__FOO__]", { data });

console.log(x);

codesandbox.io

Jon Sud
  • 10,211
  • 17
  • 76
  • 174

1 Answers1

1

I think "items[**][__FOO__!=null]" seems to work. It returns the object containing __FOO__, not the value of __FOO__ itself.

suddjian
  • 1,986
  • 2
  • 16
  • 25