From 0439aef7122cf14f7e37f44b28c28502bfd575cd Mon Sep 17 00:00:00 2001 From: Prithvipal Singh Date: Sat, 22 Feb 2020 22:50:13 +0530 Subject: [PATCH 1/2] Fixed syntax document for escape character --- SYNTAX.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SYNTAX.md b/SYNTAX.md index 9558019..94908b4 100644 --- a/SYNTAX.md +++ b/SYNTAX.md @@ -74,7 +74,7 @@ c?ildren.0 "Sara" Special purpose characters, such as `.`, `*`, and `?` can be escaped with `\`. ```go -fav\.movie "Deer Hunter" +fav\\.movie "Deer Hunter" ``` ### Arrays From 1879ad91cd090bcb340d6cd437e8ba6e290fe216 Mon Sep 17 00:00:00 2001 From: Prithvipal Singh Date: Sat, 22 Feb 2020 23:25:31 +0530 Subject: [PATCH 2/2] Addressed review suggestion --- SYNTAX.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SYNTAX.md b/SYNTAX.md index 94908b4..5ea0407 100644 --- a/SYNTAX.md +++ b/SYNTAX.md @@ -74,7 +74,15 @@ c?ildren.0 "Sara" Special purpose characters, such as `.`, `*`, and `?` can be escaped with `\`. ```go -fav\\.movie "Deer Hunter" +fav\.movie "Deer Hunter" +``` + +You'll also need to make sure that the `\` character is correctly escaped when hardcoding a path in source code. + +```go +res := gjson.Get(json, "fav\\.movie") // must escape the slash +res := gjson.Get(json, `fav\.movie`) // no need to escape the slash + ``` ### Arrays