From 569a3566842ee6bbe18d68071d973a5b68d42990 Mon Sep 17 00:00:00 2001 From: Anand Shah Date: Tue, 4 Jan 2022 17:19:46 +0530 Subject: [PATCH] If target node is array, then just append If target node is array, then just append new element to existing array --- pointer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pointer.go b/pointer.go index 798c1f1..1a7f7fa 100644 --- a/pointer.go +++ b/pointer.go @@ -129,7 +129,13 @@ func (p *JsonPointer) implementation(i *implStruct) { if _, ok := v[decodedToken]; ok { node = v[decodedToken] if isLastToken && i.mode == "SET" { - v[decodedToken] = i.setInValue + switch nodeVal := node.(type) { + case []interface{}: + nodeVal = append(nodeVal, i.setInValue) + v[decodedToken] = nodeVal + default: + v[decodedToken] = i.setInValue + } } else if isLastToken && i.mode == "DEL" { delete(v, decodedToken) }