LoadJSONBytes Extracts raw data in JSON format from different sources, i.e yaml or json files
(rawData []byte, extension string)
| 126 | |
| 127 | // LoadJSONBytes Extracts raw data in JSON format from different sources, i.e yaml or json files |
| 128 | func LoadJSONBytes(rawData []byte, extension string) ([]byte, error) { |
| 129 | var jsonRawData []byte |
| 130 | var err error |
| 131 | |
| 132 | switch extension { |
| 133 | case ".yaml", ".yml": |
| 134 | jsonRawData, err = syaml.YAMLToJSON(rawData) |
| 135 | if err != nil { |
| 136 | return nil, err |
| 137 | } |
| 138 | case ".cue": |
| 139 | return nil, errCUENotSupported |
| 140 | case ".json": |
| 141 | jsonRawData = rawData |
| 142 | default: |
| 143 | return nil, errors.New("unsupported file format") |
| 144 | } |
| 145 | |
| 146 | return jsonRawData, nil |
| 147 | } |
no outgoing calls