`$ref` key breaks object structure
Closed this issue · 2 comments
alexkuz commented
$ref
key is used internally for serializing circular objects, but it seems that jsan
doesn't escape $ref
keys if they're already there. This test is failing now:
it('handles $ref keys correctly', function() {
var obj1 = { a: { $ref: 'xxx' } };
var obj2 = jsan.parse(jsan.stringify(obj1));
assert.deepEqual(obj1, obj2);
});
Result:
AssertionError: { a: { '$ref': 'xxx' } } deepEqual { a: [Circular] }
+ expected - actual
{
- "a": {
- "$ref": "xxx"
- }
+ "a": [Circular]
}
kolodny commented
yup, I'm aware of this issue, it should be solved in the next version #1 (comment)
kolodny commented
This is solved in version 3.0.0
https://github.com/kolodny/jsan/blob/master/test/end-to-end.js#L75-L85