Giter VIP home page Giter VIP logo

jsonpath's Introduction

JSON path selection

功能说明

  1. 支持任意层级的 key path 路径定位
  2. 支持json 中数组的自由筛选

使用说明

  1. 基础语法与标准的 json path 类似,但数组部分不一样, 数组的定位标识已经独立出来了,如下:

    nodeA.nodeB.[].nodeE.nodeF.[3-5].nodeG.[-6].nodeH.[1,5,7,9-]

  2. keypath路径定位:支持以自定义的间隔符隔离各个 node, 默认的 seperator 是'.' , 如下:

    nodeA.nodeB.nodeC

  3. json 数组的筛选:支持如下五种筛选方式

    1. 支持全量

      nodeA.nodeB.[]

      nodeA.nodeB.[*]

    2. 支持索引

      nodeA.nodeB.[3]

      nodeA.nodeB.[44]

    3. 支持半开截断

      nodeA.nodeB.[-4]

      nodeA.nodeB.[7-]

    4. 支持中间截断

      nodeA.nodeB.[3-5]

      nodeA.nodeB.[55-81]

    5. 支持组合:

      nodeA.nodeB.[-5,7-9,10,13,17-]

demo

详见代码中的 testcase, 可直接运行测试 运行结果如下:

[{'a111': [{'a1111': [11111, 2, 3]}, {'a1111': [11112, 2, 3]}, {'a1111': [11113, 2, 3]}]}, {'a111': [{'a1111': [22222, 2, 3]}, {'a1111': [222223, 2, 3]}, {'a1111': [222224, 2, 3]}]}]
--------1-------
[[{'a1111': [11111, 2, 3]}, {'a1111': [11112, 2, 3]}, {'a1111': [11113, 2, 3]}], [{'a1111': [22222, 2, 3]}, {'a1111': [222223, 2, 3]}, {'a1111': [222224, 2, 3]}]]
-------2--------
[[[11111, 2, 3], [11112, 2, 3], [11113, 2, 3]], [[22222, 2, 3], [222223, 2, 3], [222224, 2, 3]]]
-------3--------
[[11111, 2, 3], [11112, 2, 3], [11113, 2, 3]]
-------4--------
[[11111, 2, 3], [11112, 2, 3], [11113, 2, 3]]
-------5--------
[11111, 2, 3]
--------6-------
([0, 1, 2, 3, 4, 5, 7, 9, 10, 12, 13, 14, 15], True)
--------7-------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.