When the object below is mapped, the empty ""
values in the array are mapped as false in the observable array:
var d2 = {
"values": [{"9", false, "", true, null, "", "", ""]
};
var viewmodel2 = ko.mapping.fromJS(d2);
When mapped back to json using ko.mapping.toJSON(viewmodel2);
this is the result:
{ "values": [
"9",
false,
false,
true,
null,
false,
false,
false] }
Notice that the last 3 string values from the array are converted back to false.
Is this a bug? or are arrays containing bools and strings not supported
Here's a fiddle for this.
This was indeed a bug and is now fixed. It was caused by two things:
The latest version, 1.2.3, is available at GitHub and a NuGet package was also created. The reproduction jsfiddle kindly created by Srluisreyes now also works!