Hi,
I have a couple of boolean userdata fields and an enum-based integer field in my scheduler and I need to transmit those values to the server. I am using scheduler.toJSON() for that purpose.
Unfortunately, my server deserialization fails because zeros and false always appear to be serialized as empty strings as a result to calling scheduler.toJSON().
I believe that the problem in the dhtmlxsheduler_serialize plugin is in line #45:
line.push(' "'+attrs[i][0]+'": "'+((attrs[i][1]?attrs[i][1](ev[attrs[i][0]]):ev[attrs[i][0]])||"").toString().replace(/\n/g,"")+'" ');
The one-liner is terrible to debug and make modifications to.
As a quick fix, I ended up using JSON.stringify() like so:
line.push(' "' + attrs[i][0] + '": "' + ((attrs[i][1] ? attrs[i][1](ev[attrs[i][0]]) : JSON.stringify(ev[attrs[i][0]]))).toString().replace(/\n/g, "") + '" ');
I am by no means happy with this solution, but at least it patches up the problem well enough.
Can you revise this line in particular and provide accurate serialization to all values that can be considered “false” (false, zero, null)?
Thank you in advance!
Bobi
NB: I am using the latest version (4.0) and latest build (130813) of the scheduler.