diff options
Diffstat (limited to 'model/node.go')
-rw-r--r-- | model/node.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/model/node.go b/model/node.go deleted file mode 100644 index fb6bae5..0000000 --- a/model/node.go +++ /dev/null @@ -1,44 +0,0 @@ -package model - -// Node of JSON tree -type Node interface { - Type() NodeType - MarshalJSON() ([]byte, error) - Set(v any) error -} - -// NewNode creates new node from value -func NewNode(value any) Node { - if value, ok := value.(Node); ok { - return value - } - switch value := value.(type) { - case string: - return &StringNode{ - Value: value, - } - case float64: - return &NumberNode{ - Value: value, - } - case int: - return &NumberNode{ - Value: float64(value), - } - case NodeObjectValue: - return &ObjectNode{ - Value: value, - Meta: make(map[string]any), - } - case NodeArrayValue: - return &ArrayNode{ - Value: value, - } - case bool: - return &BooleanNode{ - Value: value, - } - default: - return NullNode{} - } -} |