telejson
telejson copied to clipboard
Option to not replace duplicated objects/arrays/values with "_duplicate_["lorem"]" unless is in a circular dependency
Well, exactly like my title says, it would be nice to have an option to not replace duplicated objects/arrays and so on unless a circular dependency is detected.
Need more context. Do you have a repro repo you can share?
Hey, thanks for getting so quickly back to me.
So I have this config object:
{
"layout": "pass",
"level": {
"weight": 40000,
"color": "red"
},
"minLevelWeight": 40000,
"levelsDefinitions": {
"error": {
"weight": 40000,
"color": "red"
},
"fatal": {
"weight": 50000,
"color": "magenta"
},
"off": {
"weight": 1.7976931348623157e+308,
"color": "grey"
}
},
"logs": [],
"levelsCollector": {
"error": [],
"fatal": [],
"off": []
},
"tagsCollector": {},
"trackingIdsCollector": {},
"trackingIds": [],
"getLocation": true
}
If you put that through
Telejson.stringify(object, {space: 4})
You end up with:
{
"layout": "pass",
"level": {
"weight": 40000,
"color": "red"
},
"minLevelWeight": 40000,
"levelsDefinitions": {
"error": "_duplicate_[\"level\"]",
"fatal": {
"weight": 50000,
"color": "magenta"
},
"off": {
"weight": 1.7976931348623157e+308,
"color": "grey"
}
},
"logs": [],
"levelsCollector": {
"error": [],
"fatal": [],
"off": []
},
"tagsCollector": {},
"trackingIdsCollector": {},
"trackingIds": [],
"getLocation": true
}
Notice the _duplicate_[\"level\"]
and that is being replaced in a non-circular dependency context. So, it would be nice to have an option to not replace it with the string, unless is a circular dependency context. That way can be used very easily in unit/integration tests fixtures/assertions.
Any update on this?
Can we at least have a configuration level for this? Basically consider it circular if it repeats more than X times within the same circular path?