Browse Source

testing jflect... this looks promising

master
Steven Polley 2 years ago
parent
commit
4d397b874c
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      generate-structs/main.go

+ 16
- 0
generate-structs/main.go 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
}
}

Loading…
Cancel
Save