From 11a4d2ad056df6589d7b1f6fb078e593a8b1b27b Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:53 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-jsonfo.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/test-jsonfo.js 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())