jsonpath-complexity

1.0.8 • Public • Published

jsonpath-complexity

Evaluate and summarize the complexity of a JSONPath expression using a simple heuristic.

Example

var jpc = require('jsonpath-complexity');
 
const complexity = jpc.complexity('$.a[(@.b + 1 == 5)][?(@.c && @d || !@.e || @.f)]')
// {
//   components : 4,
//  expressions : 2,
//        unary : 1,
//       binary : 2,
//      logical : 3
// }

Install

Install from npm:

$ npm install jsonpath-complexity

API

jp.complexity(pathExpression)

Returns a quantitative representation of path extression complexity. Value returned is object with summary of

  • number of path components
  • number of filter and script expressions
  • number of unary operations
  • number of binary operations (arithmatic and equivalency)
  • number of logical operations (and/or)

License

MIT

Package Sidebar

Install

npm i jsonpath-complexity

Weekly Downloads

2

Version

1.0.8

License

MIT

Unpacked Size

11.4 kB

Total Files

10

Last publish

Collaborators

  • mmorsi