Skip to content

Commit

Permalink
Merge pull request #109 from goccy/feature/support-yaml-path
Browse files Browse the repository at this point in the history
Supports YAMLPath
  • Loading branch information
goccy authored Jun 4, 2020
2 parents f2d7291 + 6dddb26 commit 2ff6c9a
Show file tree
Hide file tree
Showing 3 changed files with 670 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ As of this writing, there already exists a defacto standard library for YAML pro
- Support `Scanner` or `Lexer` or `Parser` as public API
- Support `Anchor` and `Alias` to Marshaler
- Allow referencing elements declared in another file via anchors
- Extract value or AST by YAMLPath ( YAMLPath is like a JSONPath )

# Synopsis

Expand Down Expand Up @@ -272,6 +273,32 @@ control turning on/off these features

<img src="https://user-images.githubusercontent.com/209884/67358124-587f0980-f59a-11e9-96fc-7205aab77695.png"></img>

# 5. Use YAMLPath

```go
yml := `
store:
book:
- author: john
price: 10
- author: ken
price: 12
bicycle:
color: red
price: 19.95
`
path, err := yaml.PathString("$.store.book[*].author")
if err != nil {
...
}
var authors []string
if err := path.Read(strings.NewReader(yml), &authors); err != nil {
...
}
fmt.Println(authors)
// [john ken]
```

# Installation

```
Expand Down
Loading

0 comments on commit 2ff6c9a

Please sign in to comment.