AS3 parsing module for Go
This project currently supports parsing a raw AS3 declaration into a list of Go structs. It can parse a single declaration into a list of Tenant, Application, and Virtual Server objects, including as many sub properties/objects as possible. Focus is on LTM configuration for HTTPS virtual servers.
import (
"encoding/json"
"os"
as3parse "github.com/allyn-bottorff/as3"
)
// Read in a JSON object file and store the contents as a map[string]interface{}
func readJson(filePath string) map[string]interface{} {
f, err := os.ReadFile(filePath)
if err != nil {
log.Fatal("Failed to read AS3 JSON file.")
}
jsonMap := make(map[string]interface{})
json.Unmarshal(f, &jsonMap)
return jsonMap
}
func main() {
// Create a map[string]interface{}
jsonMap := readJson("./path-to-as3.json")
// Fill the AS3 Declaration with the parsed contents of the AS3 json
dec := as3parse.ParseDec(jsonMap)
// Print out basic statistic about the declaration
dec.Summarize()
}