javascript - Limit JSON stringification depth -


when stringifying object using json.stringify (or similar) there way limit stringification depth, i.e. go n levels deep object tree , ignore comes after (or better: put placeholders in there, indicating left out)?

i know json.stringify takes replacer function of form function (key, value) didn't find way depth in original object of current key-value-pair handed replacer function.

is there way default json.stringify implementation? or have reached point should implement stringification myself? or there stringification library can recommend has option?

make deep clone of object (with library such low-dash), ever pruning want , pass json.stringify. not try re-invent json.stringify, effort in wrong place.

[edit] looks did suggesting: json.stringify deep objects

i wouldn't recommend though because native json.stringify going faster , more robust

[edit] here library seems want: http://philogb.github.io/jit/static/v20/docs/files/core/core-js.html#$jit.json.prune


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -