Skip to content

Commit 74fc50e

Browse files
check that target is an object before deleting property
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
1 parent 4d2bcc4 commit 74fc50e

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/jsonata.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,9 @@ var jsonata = (function() {
13171317
};
13181318
}
13191319
for (var jj = 0; jj < deletions.length; jj++) {
1320-
delete match[deletions[jj]];
1320+
if(typeof match === 'object' && match !== null) {
1321+
delete match[deletions[jj]];
1322+
}
13211323
}
13221324
}
13231325
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"expr": "$ ~> | ** ['hi'] | {'hello': hi}, ['hi'] |",
3+
"data": {
4+
"hi": "world",
5+
"bye": null
6+
},
7+
"bindings": {},
8+
"result": {
9+
"hello": "world",
10+
"bye": null
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"expr": "$ ~> | ** [hi] | {'hello': hi}, ['hi'] |",
3+
"data": {
4+
"hi": "world",
5+
"bye": null
6+
},
7+
"bindings": {},
8+
"result": {
9+
"bye": null,
10+
"hello": "world"
11+
}
12+
}

0 commit comments

Comments
 (0)