kolodny/jsan

`$ref` key breaks object structure

Closed this issue · 2 comments

$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]
       }

yup, I'm aware of this issue, it should be solved in the next version #1 (comment)