aboutsummaryrefslogtreecommitdiff
path: root/model/objectNode.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/objectNode.go')
-rw-r--r--model/objectNode.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/model/objectNode.go b/model/objectNode.go
index 53f500d..cfa2a30 100644
--- a/model/objectNode.go
+++ b/model/objectNode.go
@@ -6,7 +6,7 @@ import (
)
type ObjectNode struct {
- Value map[string]Node
+ Value NodeObjectValue
}
func (n ObjectNode) Type() NodeType {
@@ -30,10 +30,6 @@ func (n *ObjectNode) MarshalJSON() ([]byte, error) {
}, []byte("")), nil
}
-func (n *ObjectNode) Set(k string, v any) {
- n.Value[k] = NewNode(v)
-}
-
func (n *ObjectNode) Get(k string) (Node, error) {
child, ok := n.Value[k]
if !ok {
@@ -51,3 +47,12 @@ func (n *ObjectNode) Merge(n2 *ObjectNode) {
func (n *ObjectNode) Len() int {
return len(n.Value)
}
+
+func (n *ObjectNode) Set(v any) error {
+ val, ok := v.(NodeObjectValue)
+ if !ok {
+ return fmt.Errorf("%v is not object", v)
+ }
+ n.Value = val
+ return nil
+}