purdy.js icon indicating copy to clipboard operation
purdy.js copied to clipboard

Implement serialization/deserialization similar to JSONR

Open bmille29 opened this issue 10 years ago • 2 comments

This would allow purdy to re-compute references when transmitting JSON output.

  • Useful for minimizing data transmitted to the FrontEnd applications.
  • Relationships that are one-to-many and/or many-to-many would refer to the same object.

As of now, purdy handles circular references many-to-many so it would need to be extended to also handle one-to-many relations.

Docs...

  • https://github.com/graniteds/jsonr
  • https://dzone.com/articles/json-r-json-extension-deals

bmille29 avatar Aug 13 '15 20:08 bmille29

Technically purdy handles one-to-many by treating it as circular when it isn't truly.

  • What do you think about detecting this reference
var foo = { test: 'ing' }; var bar = { one: foo, two: foo };
/* before: */ {one: {test: 2}, two: [Circular~ one]}
/* after: */  {one: {test: 2}, two: [Reference~ one]}

Strangely it also doesn't do this consistently when the object is empty

var foo = {}; var bar = { one: foo, two: foo };
{one: {}, two: {}}

A truly circular example would be...

var foo = {};  var bar = { a: 3, foo: foo }; foo.bar = bar;
{ a: 3, foo: { bar: [Circular~] } }

bmille29 avatar Aug 13 '15 21:08 bmille29

Yeah it really should be a reference and I had noticed this during implementation. However, there wasn't a way to distinguish the two easily so I had left it for a moment. I'll have a look at doing this. Thanks!

danielb2 avatar Aug 13 '15 21:08 danielb2