main.go 741 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "fmt"
  4. "git.red-green.com/david/astruct"
  5. )
  6. func main() {
  7. var a *astruct.Astruct = astruct.NewAstruct("Weather")
  8. var err error = a.ReadFile("test.json")
  9. if err != nil {
  10. fmt.Println("Err:", err)
  11. return
  12. }
  13. fmt.Println("MapLikes:")
  14. for name, m := range a.MapLikes {
  15. if name == "" {
  16. continue
  17. }
  18. fmt.Printf("%s\n", name)
  19. for k, v := range m {
  20. fmt.Printf(" '%s' = %s\n", k, v.String())
  21. }
  22. }
  23. fmt.Println("ArrayLikes:")
  24. for name, a := range a.ArrayLikes {
  25. if name == "" {
  26. continue
  27. }
  28. fmt.Printf("%s\n", name)
  29. for i, v := range a {
  30. fmt.Printf(" %d = %s\n", i, v.String())
  31. }
  32. }
  33. err = a.WriteFile("output.txt", "test", 0666)
  34. if err != nil {
  35. fmt.Println("Err:", err)
  36. return
  37. }
  38. }