Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring Objects to highest level in output #9

Open
bholbrook73 opened this issue Nov 16, 2017 · 6 comments
Open

Bring Objects to highest level in output #9

bholbrook73 opened this issue Nov 16, 2017 · 6 comments

Comments

@bholbrook73
Copy link

A complex structure can show the highest level item as 'pruned' forcing one to sift through the json atring to find the one unpruned source. Example: https://jsonblob.com/bf90de6d-caf5-11e7-8bfc-27c198b81400

In the example, the root level "server" is pruned and the original is somewhere in the json with a key NOT labeled "server" making it VERY difficult to find. It would be much better if the root level server had the object.

@Canop
Copy link
Owner

Canop commented Nov 16, 2017

Am I right in saying that what you want is having, for every set of positions an object is referred to, to keep the one which is at the lowest depth ?

If so this is an interesting request.

@bholbrook73
Copy link
Author

Yeah. If by lowest you mean lowest index.

Current
_object: { server: { ... } }, server: "-pruned-"

Desired:
_object: { server: "-pruned-" }, server: { ... }

@Canop
Copy link
Owner

Canop commented Nov 17, 2017

The request is clear.

The problem is that to do this I'd need to handle the object to stringify in two times : a BFS traversal to know where to keep and where to prune, followed by the DFS traversal which is the natural order of JSON writing.

This is feasible but not totally trivial to minimize the impact on performance.

@Canop
Copy link
Owner

Canop commented Nov 20, 2017

As the changes envisioned here would take some time to code and wouldn't be without impact on the library size and efficiency, I'd like to have more feedback from users before diving into it.

Please comment here or on Miaou.

@ralt
Copy link

ralt commented Nov 20, 2017

Could this be opt-in?

@Canop
Copy link
Owner

Canop commented Nov 20, 2017

For the performance, yes. But not reasonably for the library size.

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

No branches or pull requests

3 participants