Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improving performance of jsonpath parsing #350

Closed
wants to merge 1 commit into from

Conversation

xdlbdy
Copy link
Contributor

@xdlbdy xdlbdy commented Dec 16, 2022

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary

What is changed and how does it work?

jsonpath.JsonPathLookup will return a nested array if the path uses gt 1 range(array)
for example below data

{
  "body": {
    "alerts": [
      {
        "annotations": {
          "urlObject": [
            {
              "URL": "https://test1",
              "signature": "xxx"
            },
            {
              "URL": "https://test2",
              "signature": "xxxx"
            }
          ]
        }
      }
    ]
  }
}

if the path is $.body.alerts[:].annotations.urlObjects[:].URL it will return

[]interface{}{[]interface{}{"https://test1","https://test2"}}

so I add an function arrayCastString which will loop and add value to the string Array

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Signed-off-by: delu <delu.xu@linkall.com>
@wenfengwang wenfengwang changed the title Issue 346 feat: improving performance of jsonpath parsing Dec 16, 2022
@wenfengwang
Copy link
Contributor

link #346

github.com/linkall-labs/embed-etcd v0.1.1
github.com/linkall-labs/vanus/client v0.5.1
github.com/linkall-labs/vanus/observability v0.5.1
github.com/linkall-labs/vanus/pkg v0.5.1
github.com/linkall-labs/vanus/proto v0.5.1
github.com/linkall-labs/vanus/raft v0.5.1
github.com/ncw/directio v1.0.5
github.com/ohler55/ojg v1.14.5
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change back to github.com/oliveagle/jsonpath?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason changed to github.com/ohler55/ojg v1.14.5 isn't github.com/oliveagle/jsonpath which doesn't support array, rather than github.com/oliveagle/jsonpath has many errors, you can see the comparison in https://cburgmer.github.io/json-path-comparison/

@xdlbdy xdlbdy closed this Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants