I get the following data from the server:
var data = [{ id: 0, child: { prop1 : 'a', prop2 : 'b' } } //Child object has data ,{ id: 0, child: null } ]; // Child object is null
I am having some problems after matching data using a knockout display plugin. The problem is that the inner child object is not of the same type.
After doing this:
ko.mapping.fromJS(data, viewModel.data);
I get that the first object has a child property of type Object with data. However, the second object has a child property of type Observable , which, when unpacked, returns null.
How can I do this in both cases, the objects are of the same type, even one has a value and the other is null. Changing the way the server behaves is not an option. I expect Object and null or both Observables .
JsFiddle is here .
margabit
source share