discoveryjs/JsonDiscovery

Recursive descent operator not working

Closed this issue · 5 comments

I can't get ..ident (for non-child keys) to work from the report screen.

exdis commented

Could you describe the problem in more detail?

Example JSON Report

Expected:

Many results.

Actual:

1 result.

@texastoland This question is jora (query language) related.
Operator .. works this way:

  1. Apply subquery (on the right side) to a value (on the left)
  2. For each item of result in step 1 (it may be multiple because of array) never seen before apply step 1
  3. If all returned by subquery values already seen – return a result of unique values

In your case, at first iteration version applies to the top level object and returns a string. Ar second iteration it applies to the string and returns undefined -> return a result.

In case you want to get dependency tree in package-lock.json as a list, you should use something like that:

..(dependencies.values())

But you will loose packages names. Fix that:

..(dependencies.entries().({ name: key, ...value }))

Hope it helps.
Closing since it's not a bug.

Wow thanks for the thorough explanation! I had assumed it worked like .. in jq or in E4X to find a version at any depth. Is there something equivalent? Would it be worth tracking a request in the other repo?

...to find a version at any depth. Is there something equivalent?

It's possible with jora, but there is no special operator for this. Something like this:

..values().[version].version

What's your use case? I did not feel the need for this functionality in my tasks.
You could open an issue with a discussion in jora issues.