jx/internal/resource/decoder.go

44 lines
742 B
Go
Raw Normal View History

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package resource
import (
"encoding/json"
2024-04-05 17:22:17 +00:00
_ "fmt"
_ "github.com/xeipuuv/gojsonschema"
"gopkg.in/yaml.v3"
"io"
2024-04-05 17:22:17 +00:00
_ "log"
"strings"
)
//type JSONDecoder json.Decoder
type Decoder interface {
Decode(v any) error
}
func NewDecoder() *Decoder {
return nil
}
func NewJSONDecoder(r io.Reader) Decoder {
return json.NewDecoder(r)
}
2024-04-05 17:22:17 +00:00
func NewJSONStringDecoder(s string) Decoder {
return json.NewDecoder(strings.NewReader(s))
}
func NewYAMLDecoder(r io.Reader) Decoder {
return yaml.NewDecoder(r)
}
2024-04-05 17:22:17 +00:00
func NewYAMLStringDecoder(s string) Decoder {
return yaml.NewDecoder(strings.NewReader(s))
}
func NewProtoBufDecoder(r io.Reader) Decoder {
return nil
}