Documentation
¶
Index ¶
- func CoerceToJsonMap(ymlData InterfaceOrBytes) (model map[string]interface{}, err error)
- func FindValue(model map[string]interface{}, keys []string) interface{}
- func GetModelType(model map[string]interface{}) (modelType string, err error)
- func MarshalByExtension(model interface{}, outputFile string) (bytes []byte, err error)
- type InterfaceOrBytes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoerceToJsonMap ¶
func CoerceToJsonMap(ymlData InterfaceOrBytes) (model map[string]interface{}, err error)
CoerceToJsonMap takes a yaml byte array and coerces it to a json interface{} This is necessary because the jsonschema library only accepts valid json data types that may not match yaml. Example: yaml allows for DateTimes to be time.Time, but json requires them to be strings This also allows for structs to be passed in, and they will be converted to map[string]interface{}
func FindValue ¶
Finds the value of a key in a model in a map[string]interface{} given a slice of keys Returns nil if the key is not found or the model type is not supported Internal Recursive function so that the model can keep type safety
func GetModelType ¶
GetModelType returns the type of the model if the model is valid returns error if more than one model is found or no models are found (consistent with OSCAL spec)
func MarshalByExtension ¶
MarshalByExtension takes a model and marshals it to json or yaml based on the extension of the output file
Types ¶
type InterfaceOrBytes ¶
type InterfaceOrBytes interface {
interface{} | []byte
}
InterfaceOrBytes is an interface{} or []byte for generic functions that can support either type