Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sophiecollard/jsonpath
A JSONPath implementation in Elm
https://github.com/sophiecollard/jsonpath
elm elm-lang json json-path jsonpath
Last synced: 26 days ago
JSON representation
A JSONPath implementation in Elm
- Host: GitHub
- URL: https://github.com/sophiecollard/jsonpath
- Owner: sophiecollard
- License: apache-2.0
- Created: 2024-12-21T19:06:36.000Z (30 days ago)
- Default Branch: main
- Last Pushed: 2024-12-23T20:46:19.000Z (28 days ago)
- Last Synced: 2024-12-23T20:49:02.455Z (28 days ago)
- Topics: elm, elm-lang, json, json-path, jsonpath
- Language: Elm
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSONPath
![build status](https://github.com/sophiecollard/jsonpath/actions/workflows/build.yml/badge.svg)
A partial implementation of the [JSONPath specification](https://www.rfc-editor.org/rfc/rfc9535) in Elm.
## Installation
```sh
elm install sophiecollard/jsonpath
```## Quick start
```elm
import Json.Decode
import JsonPath
import JsonPath.ExtractorjsonSample : Json.Decode.Value
jsonSample =
... -- Your JSON hereextractedJson : Result JsonPath.Error Json.Decode.Value
extractedJson =
JsonPath.Extractor.run
"$.store.book[*].author"
sampleJson
```## Status
This package is a work in progress and does not yet support the full [JSONPath specification](https://www.rfc-editor.org/rfc/rfc9535). Below is a summary of the supported syntax:
### Identifiers
| Identifier | Syntax | Supported |
| ------------ | ------ | --------- |
| Root node | `$` | ✅ |
| Current node | `@` | ❌ |### Segments
| Segment | Syntax | Example | Supported |
| --------------- | ------ | ------------------------------- | --------- |
| Child | `.` | `$.store.book.0.author` | ✅ |
| Children | `[]` | `$.store.book[0][author,title]` | ✅ |
| All descendants | `..` | `$.store..price` | ❌ |### Selectors
| Selector | Syntax | Example | Supported |
| ----------------- | ----------------- | ----------------------------- | --------- |
| Wildcard | `*` | `$.store.book[*]` | ✅ |
| Array slice | `start:end:step` | `$.store.book[0:4:-2]` | ✅ |
| Index | `1` | `$.store.book[1,2,3] ` | ✅ |
| Name / key | `name` | `$.store.book[author,title]` | ✅ |
| Filter expression | `?` | `$.store.book[[email protected] < 10]` | ❌ |## Licence
Copyright 2024 [Sophie Collard](https://github.com/sophiecollard).
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.