Traverse all the Nodes of a JSON Object Tree with JavaScript

前端 未结 16 1641
猫巷女王i
猫巷女王i 2020-11-22 06:26

I\'d like to traverse a JSON object tree, but cannot find any library for that. It doesn\'t seem difficult but it feels like reinventing the wheel.

In XML there are

16条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 07:05

    There's a new library for traversing JSON data with JavaScript that supports many different use cases.

    https://npmjs.org/package/traverse

    https://github.com/substack/js-traverse

    It works with all kinds of JavaScript objects. It even detects cycles.

    It provides the path of each node, too.

提交回复
热议问题