Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
		
							parent
							
								
									713e7f4537
								
							
						
					
					
						commit
						11a4d2ad05
					
				
							
								
								
									
										35
									
								
								test/test-jsonfo.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/test-jsonfo.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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())
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user