allow specifying parent-node for data
This commit is contained in:
@@ -24,3 +24,4 @@ Advanced settings can be provided via a top level json key named "config". Here
|
||||
|---------------|---------------|---------------------------|
|
||||
| key-order | "Column3,Column1,Column2"| Comma separated list of column names in the desired order |
|
||||
| overwrite-file | true | Boolean indicating whether output file should be overwritten if it already exists |
|
||||
| parent-node | "results" | Specify an alternate starting key for the spreadsheet data than just the first non-config key. Useful with json structures with multiple top-level keys |
|
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
type Config struct {
|
||||
keyOrder map[int]string
|
||||
parentOverride string
|
||||
}
|
||||
|
||||
var config Config
|
||||
@@ -99,6 +100,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Get an interface that we can work with to access the sub elements
|
||||
// This doesn't seem necessary for some reason - maybe because there's only one level of depth to the configNode
|
||||
//configSlice := configInterface
|
||||
//fmt.Printf("%v\n", configSlice)
|
||||
|
||||
@@ -119,6 +121,10 @@ func main() {
|
||||
fmt.Printf("Found config element for overwriting output file\n")
|
||||
e, _ := configMap.Get(key)
|
||||
overwriteFile = e.(bool)
|
||||
} else if strings.EqualFold(key, "parent-node") {
|
||||
fmt.Printf("Found config element for forcing parent key for spreadsheet data\n")
|
||||
e, _ := configMap.Get(key)
|
||||
config.parentOverride = e.(string)
|
||||
}
|
||||
}
|
||||
} else if strings.EqualFold(topLevel[0], configNode) {
|
||||
@@ -129,6 +135,11 @@ func main() {
|
||||
parentNode = topLevel[0]
|
||||
}
|
||||
|
||||
if config.parentOverride != "" {
|
||||
fmt.Printf("Overriding parent node to '%s'\n", config.parentOverride)
|
||||
parentNode = config.parentOverride
|
||||
}
|
||||
|
||||
// Get a reference to the top level node we specified earlier
|
||||
vislice, ok := o.Get(parentNode)
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user