Edit in JSFiddle

function myViewData() {
    var self = this;
    self.firstName = ko.observable("1a");
    self.lastName = ko.observable("2b");
    self.fullName = ko.computed(function () {
        return self.firstName() + " " + self.lastName();
    });
}
$(function () {
    var vm = new myViewData()
    $("#b1").click(function () {
        vm.firstName("aa");
        vm.lastName("bb");
    });

    $("#b2").click(function () {
        ko.mapping.fromJS({firstName:'111', lastName:'222'}, {}, vm)
    });
    ko.applyBindings(vm);
});
firstName:<input type="text" data-bind="value:firstName" /><br />
lastName:<input type="text" data-bind="value:lastName" /><br />
fullName:<span data-bind="text:fullName"></span><br />
ko.toJSON:<span data-bind="text:ko.toJSON($root)"></span><br />
<input id="b1" type="button" value="手動設定每個屬性" />
<input id="b2" type="button" value="利用ko.mapping設定屬性" />

              
            
          
            
              

External resources loaded into this fiddle: