diff --git a/test/test-jsonfo.js b/test/test-jsonfo.js new file mode 100644 index 0000000..c0ea588 --- /dev/null +++ b/test/test-jsonfo.js @@ -0,0 +1,35 @@ +var JSONfo = require('../js/jam/jsonfo') + +function C(tag) { + this.text=tag; + this.data={ + text:tag, + id:function (id) {return id}, + } +} + +C.prototype.print = function () { return this.text } + + +var o1 = new C('hello world'); +var o2 = new C('hello world'); +var o3 = new C('hello world'); +var o4 = new C('hello world'); + +var data = { + x:1, + o:o2, + a:[1,2,3], + b:new Float64Array([1]), + f:function (x) { return 'test'+x}, +} + + +var ser = JSONfo.serialize(data,{C:C}); + +print(ser) + +var des = JSONfo.deserialize(ser,{C:C}); + +print(des) +print(des.o.print())