PDA

View Full Version : Allow field mapping to be zero in JsonReader



gisle
16 Mar 2007, 5:41 PM
I needed the following patch to make JsonReader able to read arrays of arrays where I map a field to index zero:


Index: data/JsonReader.js
===================================================================
--- data/JsonReader.js (revision 3619)
+++ data/JsonReader.js (working copy)
@@ -39,7 +39,7 @@
var id = (n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
for(var j = 0, jlen = fields.length; j < jlen; j++){
var f = fields.items[j];
- var map = f.mapping || f.name;
+ var map = f.mapping !== undefined ? f.mapping : f.name;
var v = n[map] !== undefined ? n[map] : f.defaultValue;
v = f.convert(v);
values[f.name] = v;

papasi
18 Mar 2007, 7:52 PM
Purely coincidence, I just discovered the same bug in ArrayReader.js and saw your post.


var k = f.mapping || j;


var k = f.mapping !== undefined ? f.mapping : j;

jack.slocum
19 Mar 2007, 5:31 AM
Both added, thanks.