34 lines
860 B
Go
34 lines
860 B
Go
package main;
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type UgoiraManifestFrame struct {
|
|
File string `json:"file"`
|
|
Delay int `json:"delay"`
|
|
}
|
|
|
|
type UgoiraManifestBodyDesc struct {
|
|
Src string `json:"src"`
|
|
OriginalSrc string `json:"originalSrc"`
|
|
MimeType string `json:"mime_type"`
|
|
Frames []UgoiraManifestFrame `json:"frames"`
|
|
}
|
|
|
|
type UgoiraManifest struct {
|
|
Error bool `json:"error"`
|
|
Message string `json:"message"`
|
|
Body UgoiraManifestBodyDesc `json:"body"`
|
|
}
|
|
|
|
func decodeUgoiraManifest(jsonData []byte) UgoiraManifest {
|
|
var manifest UgoiraManifest
|
|
if err := json.Unmarshal(jsonData, &manifest); err != nil {
|
|
die("Could not parse manifest JSON: %s", err)
|
|
}
|
|
if manifest.Error {
|
|
die("Manifest returned error: %s", manifest.Message)
|
|
}
|
|
return manifest
|
|
}
|