lloyd / JSONSelect

CSS-like selectors for JSON
http://jsonselect.org
ISC License
1.59k stars 116 forks source link

Enhancement: Excluding properties from traversal #59

Open dbo opened 10 years ago

dbo commented 10 years ago

The selected object tree needs to be acyclic, which is quite inconvenient if you are cross referencing branches. An indirection via an external map helps, but is not really elegant, IMO. I'd rather suggest a "special" key being excluded on traversal, e.g. "__meta" (should be customizable) which could serve as such.

In conjuction with issue #58 (parent access in forEach), this offers a lot of flexibility traversing an object tree.

What do you think?

dbo commented 10 years ago

I am proposing something like https://github.com/dbo/JSONSelect/commit/be8f5b4a0c8d3fc2601c2177d82872736e242dd4

danvk commented 10 years ago

I implemented something like this in pyjsonselect. I hadn't thought of the circular reference use case, but it can be a huge performance boost for any large object.