testing jflect... this looks promising

This commit is contained in:
Steven Polley 2018-08-15 16:50:03 -06:00
parent 8fec1c86c7
commit 4d397b874c

View File

@ -1,7 +1,9 @@
package main
import (
"bytes"
"fmt"
"jflect"
"log"
"os"
"strconv"
@ -26,6 +28,10 @@ func main() {
log.Fatalf("could get get FATs: %s", err)
}
w, _ := os.Create("flexible-asset-types.go")
w.WriteString("package itglue\n\n")
for _, fat := range fats.Data {
fmt.Printf("%s - %s\n", fat.FlexibleAssetTypeData.ID, fat.FlexibleAssetTypeData.Attributes.Name)
id, err := strconv.Atoi(fat.ID)
@ -38,6 +44,16 @@ func main() {
log.Fatalf("could get flexible asset with type ID %d: %s", id, err)
}
r := bytes.NewReader(fa)
fatName := fmt.Sprintf("FlexAsset%s", fat.FlexibleAssetTypeData.ID)
err = jflect.Read(fatName, r, w)
if err != nil {
log.Fatalf("could not parse json to struct: %s", err)
}
w.WriteString("\n\n")
//name := &fat.FlexibleAssetTypeData.Attributes.Name
}
}