Skip to content

Commit

Permalink
update properties.AppendPropertiesWithJSON to account for empty prefi…
Browse files Browse the repository at this point in the history
…xes properly
  • Loading branch information
thisisaaronland committed Dec 16, 2020
1 parent e2c5b75 commit 2ca38b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"
"github.com/aaronland/go-roster"
"github.com/paulmach/go.geojson"
"github.com/skelterjohn/geom"
wof_geojson "github.com/whosonfirst/go-whosonfirst-geojson-v2"
"github.com/whosonfirst/go-whosonfirst-spatial/filter"
"github.com/paulmach/go.geojson"
"github.com/whosonfirst/go-whosonfirst-spr"
"net/url"
"sort"
Expand Down
15 changes: 13 additions & 2 deletions properties/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ func AppendPropertiesWithJSON(ctx context.Context, source []byte, target []byte,

e = strings.Replace(e, "*", "", -1)

props := gjson.GetBytes(source, "properties")
var props gjson.Result

if prefix != "" {
props = gjson.GetBytes(source, ".")
} else {
props = gjson.ParseBytes(source)
}

for k, _ := range props.Map() {

Expand All @@ -36,7 +42,12 @@ func AppendPropertiesWithJSON(ctx context.Context, source []byte, target []byte,

for _, p := range paths {

get_path := fmt.Sprintf("properties.%s", p)
get_path := p

if prefix != "" {
get_path = fmt.Sprintf("%s.%s", prefix, get_path)
}

set_path := p

if prefix != "" {
Expand Down

0 comments on commit 2ca38b1

Please sign in to comment.