aboutsummaryrefslogtreecommitdiff
path: root/model/arrayNode.go
diff options
context:
space:
mode:
authorNeonXP <i@neonxp.dev>2022-11-21 04:46:32 +0300
committerNeonXP <i@neonxp.dev>2022-11-21 04:46:32 +0300
commit0d431048d3e68609b90306efd9ed015143ae651f (patch)
tree2a5fe21654bb9af02a0419722f2cd80d588465a2 /model/arrayNode.go
parent4054a50ce4232ebfc4dae043863ad96d46b25b43 (diff)
added set method
Diffstat (limited to 'model/arrayNode.go')
-rw-r--r--model/arrayNode.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/model/arrayNode.go b/model/arrayNode.go
index 203e01c..319f223 100644
--- a/model/arrayNode.go
+++ b/model/arrayNode.go
@@ -30,6 +30,15 @@ func (n *ArrayNode) MarshalJSON() ([]byte, error) {
}, []byte("")), nil
}
+func (n *ArrayNode) Set(v any) error {
+ val, ok := v.(NodeArrayValue)
+ if !ok {
+ return fmt.Errorf("%v is not array", v)
+ }
+ n.Value = val
+ return nil
+}
+
func (n *ArrayNode) Index(idx int) (Node, error) {
if len(n.Value) <= idx {
return nil, fmt.Errorf("index %d out of range [0...%d]", idx, len(n.Value)-1)