Commit 6ee9f87
committed
Added Escape function
This commit adds the Escape function for escaping a path
component, making it possible to directly querying keys that have
special characters like dots.
```
json := `{
"user":{
"first.name": "Janet",
"last.name": "Prichard"
}
}`
user := gjson.Get(json, "user")
println(user.Get(gjson.Escape("first.name")).String())
println(user.Get(gjson.Escape("last.name")).String())
// Output:
// Janet
// Prichard
```
See #3331 parent be1bb7d commit 6ee9f87
2 files changed
+35
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3410 | 3410 | | |
3411 | 3411 | | |
3412 | 3412 | | |
3413 | | - | |
| 3413 | + | |
3414 | 3414 | | |
3415 | 3415 | | |
3416 | 3416 | | |
| |||
3425 | 3425 | | |
3426 | 3426 | | |
3427 | 3427 | | |
3428 | | - | |
3429 | | - | |
3430 | | - | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
3431 | 3431 | | |
3432 | 3432 | | |
3433 | | - | |
3434 | | - | |
3435 | | - | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
3436 | 3448 | | |
3437 | 3449 | | |
3438 | | - | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
3439 | 3453 | | |
3440 | 3454 | | |
3441 | 3455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2701 | 2701 | | |
2702 | 2702 | | |
2703 | 2703 | | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
0 commit comments