fabricjs serialize problem

by ps7566

HTML

<!-- <button onClick="printObj()">Print rect</button> -->
<!-- <button onClick="addChild()">Add Child</button> -->
<button onClick="serialize()">Serialize</button>
<button onClick="loadJSON()">Load JSON</button>
<!-- <button onClick="canvas.remove(r)">Delete Rect</button>  -->
<canvas id="c"></canvas>

JavaScript

var canvas = new fabric.Canvas("c",{
	width: 600,
  height: 500,
  backgroundColor: 'cyan'
});
var a = new fabric.Rect({
  left: 70,
  top: 70,
  fill: 'blue',
  width: 100,
  height: 100
});
var b = new fabric.Rect({
  left: 75,
  top: 75,
  fill: 'red',
  width: 50,
  height: 50
});
b.another = 'property';//this custom property is losed in event observer after serialize;
a.childs = [];
a.childs.push(b);
a.childs.push(b);
canvas.add(a);
//function printObj(){
//	console.log(r);
//}
//function addChild(){
//	r.childs.push(s);
//}
var json;
function serialize(){
	json = JSON.stringify(canvas.toJSON(['childs','another']));
  console.log(json);
}
function loadJSON(){
	canvas.loadFromJSON(json);
}
canvas.observe("mouse:up",function(e){
	if(e.target != null){
  	console.log(e.target);
    alert(e.target.childs[0].another);//why this is undefined after serialize and load json? 
  }
});

fabric.Rect.prototype.toObject = (function(toObject) {
    return function(propertiesToInclude) {
        var data = toObject.call(this,propertiesToInclude),childs=[];
        
        if(this.childs && this.childs.length){
        	 for(var i= 0 ; i<this.childs.length; i++){
           		childs.push(this.childs[i].toObject(propertiesToInclude));
           }
           
        }
        data.childs = childs;
        
        return data;
    };
})(fabric.Rect.prototype.toObject);
fabric.Rect.fromObject = function(object, callback, forceAsync) {
 
    var obj = fabric.Object._fromObject('Rect', object, null, false);
    console.log(obj);
    obj.childs = [];
    if(object.childs && object.childs.length){
    	 for(var i= 0 ; i<object.childs.length; i++){
           obj.childs[i] = fabric.Object._fromObject('Rect', object.childs[i], null, 0);
       }
    }
    
    return callback ? callback(obj) : obj;
  };

//The project has to be programmed in this way. with an array, event observer and custom properties. can not it be a different way.