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

nesting level #17

Open
Roman-Romanov97 opened this issue Dec 5, 2019 · 3 comments
Open

nesting level #17

Roman-Romanov97 opened this issue Dec 5, 2019 · 3 comments

Comments

@Roman-Romanov97
Copy link

Roman-Romanov97 commented Dec 5, 2019

can I somehow control the level of nesting? How is it easiest for me to implement?
nesting (int 0-5, default 3)

@abodelot
Copy link
Owner

abodelot commented Dec 5, 2019

Hi, I don't understand what you mean by nesting level, can you please elaborate?

Is this about the width of indentation?

@Roman-Romanov97
Copy link
Author

Hi, nope, I mean that there is a parameter that minimizes all the nodes (collapsed), but there is no parameter that indicates what level of nesting should be minimized by default (nestingLvl)
{collapsed: false, withQuotes: false, withLinks: false, nestingLvl: 3}
1lvl - { id: 1001, type: "donut", name: "Cake", 2lvl - available: { store: 42, warehouse: 600 }, toppings: [ 3lvl - {2 items}, # collapsed by nestingLvl param ], }

@abodelot
Copy link
Owner

abodelot commented Dec 8, 2019

OK I understand what you want to achieve! This could be useful, but I don't know if I'll have time for this.

If you want to give it a shot and implement this option, you would need to add a depth argument to the recursive json2html function, which should be incremented before each recursive call:

function json2html(json, depth, options) {
  // ...
  json2html(json, depth + 1, options)
}

And set the collapsed CSS class on a elements according to the nesting level option value.

Hope this helps.

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

2 participants