gno icon indicating copy to clipboard operation
gno copied to clipboard

feat(p/json): JSON path support

Open notJoon opened this issue 1 year ago • 6 comments

Description

Implemented a feature that parses JSONPath expression using a state machine and extracts data matching the specified path from the input JSON data.

JSONPath is an expression used to select and filter specific data within a JSON data. This implementation supports the basic functionalities of JSONPath.

Here's a table summarizing the supported JSONPath features now:

Symbol Description Example
Root Object($) Represents the root object of the JSON. All paths start with this symbol $.store.book[0].title
Wildcard(*) Selects all elements of any object or array. $.store.*
Subscript Operator([]) Selects a specific element of an array or object using an index or a key. $.store.book[0]
Deep Scan(..) Selects the specified property regardless of the depth in the JSON. $..price
Slice Operator(:) Selects elements within a range in an array. $.store.book[0:2]

Currently, This implementation focuses on the basic functionality of JSON path expressions to prevent the size of PR is bigger. So, the filter expressions(?(@)) are not implemented yet. but this feature will be added with complex filtering and built-in functions.

I expect, with this JSONPath parser, users can easily extract and utilize desired information from within JSON data.

notJoon avatar Apr 16 '24 10:04 notJoon

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Apr 16 '24 10:04 codecov[bot]

Hello @notJoon . Some CI tests from Sept. 3 failed. Maybe merge master again to see if they pass?

jefft0 avatar Oct 21 '24 07:10 jefft0

Hello @notJoon . Some CI tests from Sept. 3 failed. Maybe merge master again to see if they pass?

It causes an unknown panic, so I'll leave it in draft until I resolve it.

notJoon avatar Oct 21 '24 08:10 notJoon

Only 3 failed tests this time :-) .

jefft0 avatar Oct 21 '24 08:10 jefft0

I think the "examples/fmt" failure is easy to fix. "Some gno files are not formatted, please run 'make fmt'."

jefft0 avatar Oct 21 '24 08:10 jefft0

Removed the review/triage-pending label because the author converted this PR to Draft status. When Draft status is removed, we will add the label again.

jefft0 avatar Oct 21 '24 16:10 jefft0

Closing for cleanup on old PRs

thehowl avatar Apr 08 '25 15:04 thehowl