我正在寻找一种有效的方法将我的Ember对象转换为json字符串,以便在下面的websocket消息中使用它
/*
* Model
*/
App.node = Ember.Object.extend({
name: 'theName',
type: 'theType',
value: 'theValue',
})
Run Code Online (Sandbox Code Playgroud)
websocket方法:
App.io.emit('node', {node: hash});
Run Code Online (Sandbox Code Playgroud)
hash应该是节点的json表示.{name:thename,type:theType,..}必须有一个快速的在线人才能做到这一点.我不想手工做,因为我有很多属性,他们很可能会改变..