Skip to content

Commit ad821ae

Browse files
fix for set error: Invalid JSON on returnEmptyFields: true dschnelldavis#282
1 parent cb671cf commit ad821ae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib/src/shared/jsonpointer.functions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ export class JsonPointer {
392392
console.error(`forEachDeep error: Iterator is not a function:`, fn);
393393
return;
394394
}
395+
const firstPointerPart = pointer.split('/')[1];
396+
if (firstPointerPart && rootObject.hasOwnProperty(firstPointerPart)) {
395397
if (!bottomUp) { fn(object, pointer, rootObject); }
398+
}
396399
if (isObject(object) || isArray(object)) {
397400
for (let key of Object.keys(object)) {
398401
const newPointer = pointer + '/' + this.escape(key);

0 commit comments

Comments
 (0)