/** * @author Ed Spencer * @class Ext.data.JsonWriter * @extends Ext.data.Writer * *Writer that outputs model data in JSON format
*/ Ext.data.JsonWriter = Ext.extend(Ext.data.Writer, { /** * @cfg {String} root The key under which the records in this Writer will be placed. Defaults to 'records'. * Example generated request:*/ root: 'records', /** * @cfg {Boolean} encode True to use Ext.encode() on the data before sending. Defaults to false. */ encode: false, //inherit docs writeRecords: function(request, data) { if (this.encode === true) { data = Ext.encode(data); } request.jsonData = request.jsonData || {}; request.jsonData[this.root] = data; return request; } }); Ext.data.WriterMgr.registerType('json', Ext.data.JsonWriter);{'records': [{name: 'my record'}, {name: 'another record'}]}