Documentation
¶
Overview ¶
Package codec provides capabilities for marshalling and unmarshalling OpenCLI documents.
It supports JSON and YAML formats and automatically validates specs against the official OpenCLI schema definitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON encodes a spec.Document into JSON bytes.
Example:
data, err := codec.MarshalJSON(doc)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
func MarshalYAML ¶
MarshalYAML encodes a spec.Document into YAML bytes.
Example:
data, err := codec.MarshalYAML(doc)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
func UnmarshalJSON ¶
UnmarshalJSON decodes a JSON-encoded OpenCLI document into a spec.Document.
Example:
doc, err := codec.UnmarshalJSON([]byte(`{"opencliVersion": "0.1.0", ...}`))
if err != nil {
log.Fatal(err)
}
Types ¶
Click to show internal directories.
Click to hide internal directories.