From bf13236e3ef04a3bdc9ead7dcfdb71d296b24b07 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 11 May 2021 00:17:02 +0200 Subject: skate-map: jq compat --- skate/map.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'skate') 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()) -- cgit v1.2.3