jquery.json-viewer icon indicating copy to clipboard operation
jquery.json-viewer copied to clipboard

nesting level

Open Roman-Romanov97 opened this issue 6 years ago • 3 comments

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

Roman-Romanov97 avatar Dec 05 '19 14:12 Roman-Romanov97

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

Is this about the width of indentation?

abodelot avatar Dec 05 '19 21:12 abodelot

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 ], }

Roman-Romanov97 avatar Dec 06 '19 09:12 Roman-Romanov97

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.

abodelot avatar Dec 08 '19 11:12 abodelot