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

Added json_path function #4225

Merged
merged 3 commits into from
Jun 23, 2023
Merged

Added json_path function #4225

merged 3 commits into from
Jun 23, 2023

Conversation

jkroepke
Copy link
Contributor

PR Description

This PR add a json_path function to stdlib. See #4171 for use cases.

Which issue(s) this PR fixes

Fixes #4171

Notes to the Reviewer

Coming from https://cburgmer.github.io/json-path-comparison/, I choice github.com/ohler55/ojg. The library is MIT licensed, seems actively maintained and has zero dependencies.

PR Checklist

  • CHANGELOG updated
  • Documentation added
  • Tests updated

@jkroepke jkroepke requested review from clayton-cornell and a team as code owners June 21, 2023 19:14
@mattdurham mattdurham self-requested a review June 21, 2023 20:32
Copy link
Collaborator

@mattdurham mattdurham left a comment

Choose a reason for hiding this comment

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

This looks good to me pending Clayton checking doc, great work!


`json_path` always return a list of values. If the jsonpath expression does not match any values, an empty list is returned.

> Remember to escape double quotes when passing JSON string literals to `json_path`.
Copy link
Member

Choose a reason for hiding this comment

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

It's implied, but could we also mention that we can pass the string export of another component directly if it's valid JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do a bit copy/paste from json_encode. Is this enough?

Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

Copy link
Contributor

@clayton-cornell clayton-cornell left a comment

Choose a reason for hiding this comment

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

Some suggestions for the doc

docs/sources/flow/reference/stdlib/json_path.md Outdated Show resolved Hide resolved
@jkroepke
Copy link
Contributor Author

@clayton-cornell thanks, commited.

@jkroepke jkroepke requested a review from clayton-cornell June 23, 2023 07:12
@mattdurham mattdurham merged commit fe2f702 into grafana:main Jun 23, 2023
@jkroepke jkroepke deleted the json_path branch June 23, 2023 15:28
clayton-cornell added a commit that referenced this pull request Aug 14, 2023
* Added json_path function

* Add doc note about local.file

* Update docs/sources/flow/reference/stdlib/json_path.md

Co-authored-by: Clayton Cornell <[email protected]>

---------

Co-authored-by: Clayton Cornell <[email protected]>
clayton-cornell added a commit that referenced this pull request Aug 14, 2023
* Added json_path function

* Add doc note about local.file

* Update docs/sources/flow/reference/stdlib/json_path.md

Co-authored-by: Clayton Cornell <[email protected]>

---------

Co-authored-by: Clayton Cornell <[email protected]>
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 22, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

river: Add jsonpath function
6 participants