You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am setting a value of undefined on an object using your library, and this removes the property completely. I would like to keep the property and really set its property to undefined.
I also put an example here:
consta={value: 5};jsonpointer.set(a,'value',undefined);console.log(a);// outputs something like {}, but I would like to have {value: undefined}
I’d accept a PR that implements set(obj, pointer, value, {allowUndefinedValue: true}). Bonus points for a way to instantiate a set fun that has that option bound to it for each invocation.
One thing to note is there is NOT undefined in JSON, while undefined is a valid value in JavaScript object. So for [1, undefined, 2] in JavaScript, when it's converted to JSON, it becomes [1, null, 2], which may have undesired effect.
Activity
jperasmus commentedon May 30, 2019
Looks like it is intentional:
node-jsonpointer/jsonpointer.js
Line 42 in 2a9875e
janl commentedon Jul 3, 2020
yeah, this is by design #27
I’d accept a PR that implements
set(obj, pointer, value, {allowUndefinedValue: true}). Bonus points for a way to instantiate a set fun that has that option bound to it for each invocation.Please file a PR directly.
jperasmus commentedon Jul 4, 2020
What about exposing a new
setuporsettingsfunction that can be called to globally apply this and possible future config options?Is this something you would be interested in?
janl commentedon Nov 1, 2021
sure, all of this sounds good
johnmiroki commentedon Dec 31, 2021
One thing to note is there is NOT undefined in JSON, while undefined is a valid value in JavaScript object. So for [1, undefined, 2] in JavaScript, when it's converted to JSON, it becomes [1, null, 2], which may have undesired effect.