testing jflect... this looks promising
This commit is contained in:
parent
8fec1c86c7
commit
4d397b874c
@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"jflect"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -26,6 +28,10 @@ func main() {
|
|||||||
log.Fatalf("could get get FATs: %s", err)
|
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 {
|
for _, fat := range fats.Data {
|
||||||
fmt.Printf("%s - %s\n", fat.FlexibleAssetTypeData.ID, fat.FlexibleAssetTypeData.Attributes.Name)
|
fmt.Printf("%s - %s\n", fat.FlexibleAssetTypeData.ID, fat.FlexibleAssetTypeData.Attributes.Name)
|
||||||
id, err := strconv.Atoi(fat.ID)
|
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)
|
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
|
//name := &fat.FlexibleAssetTypeData.Attributes.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user