Serializing to JSON

I’ve noticed that javascript JSON.parse can’t parse the output by scheduler.toJSON() since the keys in object are not wrapped in double quotes. So I made a small change in the function, now with JSON.parse method we can convert it into objects back.

scheduler.toJSON = function(){
	var json = [];
	var attrs = this.data_attributes();
	for (var a in this._events){
		var ev = this._events[a];
		if (ev.id.toString().indexOf("#")!=-1) continue;
		var ev = this._events[a];
		var line =[];	
		for (var i=0; i < attrs.length; i++)
			line.push(' "'+attrs[i][0]+'":"'+((attrs[i][1]?attrs[i][1](ev[attrs[i][0]]):ev[attrs[i][0]])||"").toString().replace(/\n/g,"")+'" ');
		json.push("{"+line.join(",")+"}");
	}
	return "["+json.join(",\n")+"]";
};

Notice that the change is here: line.push(’ “’+attrs[i][0]+’”:"’ …

Since on the backend I have NodeJS and couchdb, using JSON would be the fastest way for me manipulate the objects.

Hello,

Thank you for reporting this!

:ugeek: Nice to hear

Kind regards,
Ilya