aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-11 00:17:02 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-11 00:17:02 +0200
commitbf13236e3ef04a3bdc9ead7dcfdb71d296b24b07 (patch)
treee6a49733488a1e44cd5a12d0a24e290e04c9d41a /skate
parentcadf89f52311a864e59f0227ebcce28e0051245b (diff)
downloadrefcat-bf13236e3ef04a3bdc9ead7dcfdb71d296b24b07.tar.gz
refcat-bf13236e3ef04a3bdc9ead7dcfdb71d296b24b07.zip
skate-map: jq compat
Diffstat (limited to 'skate')
-rw-r--r--skate/map.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/skate/map.go b/skate/map.go
index 7000f6a..f401af7 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -121,8 +121,13 @@ func Identity(p []byte) ([][]byte, error) {
}
// CreateFixedMapper extract the value from a given fixed json key, e.g.
-// ".biblio.doi" and the like. Returns a function that maps doc to (value, doc).
+// "biblio.doi" and the like. Returns a function that maps doc to (value, doc).
func CreateFixedMapper(field string) Mapper {
+ if len(field) > 0 && field[0] == "." {
+ // gjson is not jq, we do not use a leading dot, so remove it, if
+ // accidentally used here
+ field = field[1:]
+ }
f := func(p []byte) ([][]byte, error) {
result := gjson.GetBytes(p, field)
key := []byte(result.String())