Documentation
¶
Index ¶
- Constants
- Variables
- func InterpretAST(node ast.JsonNode, variables map[string]interface{}, ...) ([]byte, error)
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIntoTemplate(v interface{}) ([]byte, error)
- func MarshalWithVariables(v interface{}, variables map[string]interface{}) ([]byte, error)
- func NewASTInterpreter(variables map[string]interface{}, marshaler ast.MarshalerFunc) *standardVisitor
- func NewErrFieldCannotSetOrNotfound(fieldName string) error
- func NewErrorFieldNotFound(field string) error
- func NewErrorFiledNotFound(fieldName string) error
- func NewErrorInternalExpectingArrayInsidePointerButFindOthers(kind string) error
- func NewErrorInternalExpectingStructButFindOthers(kind string) error
- func NewErrorInternalExpectingStructInsidePointerButFindOthers(kind string) error
- func NewErrorInternalFieldTypeNotMatchAST(kind string) error
- func NewErrorInternalMapKeyValueKindNotMatch(kind string, value interface{}) error
- func NewUnMarshallOptions(variables map[string]interface{}, marshaler ast.MarshalerFunc, ...) *unmarshallOptions
- func NewVariableNotFound(variable string) error
- func ParseJsonExtendDocument(reader io.Reader, variables map[string]interface{}) ([]byte, error)
- func PrettyInterpret(node ast.JsonNode, variables map[string]interface{}, ...) ([]byte, error)
- func Unmarshal(reader io.Reader, variables map[string]interface{}, out interface{}) error
- func UnmarshallAST(node ast.JsonNode, variables map[string]interface{}, ...) error
- type BufferWriter
- type ErrorFieldNotExist
- type PrettyPrintVisitor
- func (s *PrettyPrintVisitor) GetOutput() []byte
- func (s *PrettyPrintVisitor) VisitArrayNode(node *ast.JsonArrayNode) error
- func (s *PrettyPrintVisitor) VisitBooleanNode(node *ast.JsonBooleanNode) error
- func (s *PrettyPrintVisitor) VisitKeyValuePairNode(node *ast.JsonKeyValuePairNode) error
- func (s *PrettyPrintVisitor) VisitNullNode(node *ast.JsonNullNode) error
- func (s *PrettyPrintVisitor) VisitNumberNode(node *ast.JsonNumberNode) error
- func (s *PrettyPrintVisitor) VisitObjectNode(node *ast.JsonObjectNode) error
- func (s *PrettyPrintVisitor) VisitStringNode(node *ast.JsonStringNode) error
- func (s *PrettyPrintVisitor) VisitStringWithVariableNode(node *ast.JsonExtendedStringWIthVariableNode) error
- func (s *PrettyPrintVisitor) VisitVariableNode(node *ast.JsonExtendedVariableNode) error
- func (s *PrettyPrintVisitor) WriteSymbol() error
Constants ¶
View Source
const ( ExpectingStructInPointerFindOthers = "expecting struct inside pointer but find %s" ExpectingArrayInPointerFindOthers = "expecting array inside pointer but find %s" FieldTypeNotMatchAST = "field type %s is not of ast collection node type" FieldNotFound = "field with tag %s not found" )
View Source
const ( ExpectingStructFindOthers = "expecting struct but find %s" VariableNotFound = "variable value for %s not found" FieldNotValid = "field not exist %s" KVKindNotMatch = "expect %s as key but value is not :%#v" )
Variables ¶
View Source
var ( ErrorInterpreSymbolFailure = errors.New("have symbol not consumed") ErrorInterpretVariable = errors.New("error when interpret variable values") ErrorInternalInterpreterOutdated = errors.New("interpreter not update as the ast grows") ErrorKeyStringVariableNotResolve = errors.New("find string variable as object key, but the variable value is missing") ErrorVariableValueNotJsonValueType = errors.New("variable value should be json value type") ErrorVariableValueNotFound = errors.New("variable value is not found") ErrorInternalGetPrimitiveValue = errors.New("try to get primitive value from none-primitive type") ErrorInternalShouldBeArrayOrSlice = errors.New("should be array or slice") ErrorInternalMapKeyTypeNotMatchValue = fmt.Errorf("expect bool as key but value is not bool") ErrorInternalExpectingPrimitive = errors.New("expecting primitive values but find others") ErrorInternalPtrToArrayFindNotArray = errors.New("expecting pointer to array, but underlying object not array") ErrSliceOrArrayNotInit = errors.New("slice/array not init") ErrorUnmarshalStackNoKV = errors.New("there should not be kv pair in stack") ErrorNotSupportedASTNode = errors.New("not supported ast node") ErrorInternalSymbolStackIncorrect = errors.New("interpret symbol stack invalid") )
View Source
var ( ErrorReflectNotObject = errors.New("out element is not map nor struct") ErrorReflectInvalidMapKey = errors.New("map key type should be string") ErrOutNotNilPointer = errors.New("out is nil pointer") )
View Source
var ( ErrOutNotPointer = errors.New("out is not pointer") ErrorInternalNoneResolvable = errors.New("expecting dependendent element to resolve") ErrorInternalUnsupportedMapKeyKind = fmt.Errorf("unsupported map key to continue") ErrorStringVariableNotResolveOnKeyLocation = errors.New("object key contain string variable that has no variable value") ErrorInternalDependentResolverHasOnResolveLocation = errors.New("dependent value has no idex or object key set to resolve") ErrorPrimitiveTypeCannotResolveDependency = errors.New("pritimive type cannot resolve dependency") ErrorInternalExpectingArrayLikeObject = errors.New("expecting array like object but find others") ErrorInvalidUnmarshalResult = errors.New("invalid unmarshal result") ErrorInvalidTag = errors.New("invalid json tag") ErrorUnsupportedDataKind = errors.New("unsupported variable data kind") ErrorInvalidJson = errors.New("invalid json") ErrorSelfCallTooDeep = errors.New("recursion depth exceeded") )
View Source
var (
ErrorUnmarshalNotSlice = errors.New("unmarshal to a non-slice variable")
)
Functions ¶
func InterpretAST ¶ added in v0.3.2
func MarshalIntoTemplate ¶ added in v0.5.0
func MarshalWithVariables ¶ added in v0.5.1
func NewASTInterpreter ¶ added in v0.4.0
func NewASTInterpreter(variables map[string]interface{}, marshaler ast.MarshalerFunc) *standardVisitor
func NewErrFieldCannotSetOrNotfound ¶ added in v0.3.0
func NewErrorFieldNotFound ¶ added in v0.3.1
func NewErrorFiledNotFound ¶ added in v0.3.0
func NewErrorInternalExpectingArrayInsidePointerButFindOthers ¶ added in v0.3.0
func NewErrorInternalExpectingStructButFindOthers ¶ added in v0.3.0
func NewErrorInternalExpectingStructInsidePointerButFindOthers ¶ added in v0.3.0
func NewErrorInternalFieldTypeNotMatchAST ¶ added in v0.3.0
func NewErrorInternalMapKeyValueKindNotMatch ¶ added in v0.3.0
func NewUnMarshallOptions ¶ added in v0.3.0
func NewUnMarshallOptions(variables map[string]interface{}, marshaler ast.MarshalerFunc, unmarshaler ast.UnmarshalerFunc) *unmarshallOptions
func NewVariableNotFound ¶ added in v0.3.0
func ParseJsonExtendDocument ¶ added in v0.4.1
func PrettyInterpret ¶ added in v0.3.2
func UnmarshallAST ¶ added in v0.3.0
func UnmarshallAST(node ast.JsonNode, variables map[string]interface{}, marshaler ast.MarshalerFunc, unmarshaler ast.UnmarshalerFunc, out interface{}) error
use marshaler to deal with the string variable/variable, use unmarshaler to deal with the json tag `string` option
Types ¶
type BufferWriter ¶ added in v0.4.0
type ErrorFieldNotExist ¶ added in v0.4.0
type ErrorFieldNotExist struct {
// contains filtered or unexported fields
}
func NewErrorFieldNotValid ¶ added in v0.3.0
func NewErrorFieldNotValid(field string) ErrorFieldNotExist
func (ErrorFieldNotExist) Error ¶ added in v0.4.0
func (e ErrorFieldNotExist) Error() string
type PrettyPrintVisitor ¶ added in v0.4.0
type PrettyPrintVisitor struct {
// contains filtered or unexported fields
}
func NewPPInterpreter ¶ added in v0.3.2
func NewPPInterpreter(variables map[string]interface{}, marshaler ast.MarshalerFunc) *PrettyPrintVisitor
func (*PrettyPrintVisitor) GetOutput ¶ added in v0.4.0
func (s *PrettyPrintVisitor) GetOutput() []byte
func (*PrettyPrintVisitor) VisitArrayNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitArrayNode(node *ast.JsonArrayNode) error
func (*PrettyPrintVisitor) VisitBooleanNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitBooleanNode(node *ast.JsonBooleanNode) error
func (*PrettyPrintVisitor) VisitKeyValuePairNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitKeyValuePairNode(node *ast.JsonKeyValuePairNode) error
func (*PrettyPrintVisitor) VisitNullNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitNullNode(node *ast.JsonNullNode) error
func (*PrettyPrintVisitor) VisitNumberNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitNumberNode(node *ast.JsonNumberNode) error
func (*PrettyPrintVisitor) VisitObjectNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitObjectNode(node *ast.JsonObjectNode) error
func (*PrettyPrintVisitor) VisitStringNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitStringNode(node *ast.JsonStringNode) error
func (*PrettyPrintVisitor) VisitStringWithVariableNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitStringWithVariableNode(node *ast.JsonExtendedStringWIthVariableNode) error
func (*PrettyPrintVisitor) VisitVariableNode ¶ added in v0.4.0
func (s *PrettyPrintVisitor) VisitVariableNode(node *ast.JsonExtendedVariableNode) error
func (*PrettyPrintVisitor) WriteSymbol ¶ added in v0.4.0
func (s *PrettyPrintVisitor) WriteSymbol() error
Click to show internal directories.
Click to hide internal directories.