JSON.stringify(data)
is removing certain of data
Tried the below resolution but it did not work either
const obj = {
prop1: 'value1'
};
Object.defineProperty(obj, 'prop2', {
value: 'value2',
enumerable: false
});
console.log(JSON.stringify(obj));
Is there a way to stop JSON.stringify from removing extracts of data ?
2
Answers
enumerable
false
makes your property transparent to some functionalities. Try setting it totrue
.It is explicitly documented that when using
JSON.stringify
:You’ve set the property to
enumerable: false
so it won’t be included.You can’t change that behaviour of
JSON.stringify
. You could change your property definition.