English 中文(简体)
Knockout.js:ko.toJSON没有将眼光转换为JSON
原标题:Knockout.js: ko.toJSON does not convert viewmodel to JSON

我非常奇怪的是,我不把我的看法转换成国际科学学会的JSON。 如果在我的系统中删除同一法典,它会进行罚款,并将视像素转换为名人。 混合法并不产生相同的结果。

这正是我的看法。 致开幕词。

关于国际住户调查:

"{"__ko_mapping__":{"ignore":[],"include":["_destroy"],"copy":[],"mappedProperties": {"__type":true,"Prop1":true,"Prop2":true,"Prop3":true,"Prop4":true,"Prop5":true}}}"

当地

{"__type":"DealerModel","Prop1":"","Prop2":"","Prop3":"","Prop4":"","Prop5":"Some Name  ltd"}}}"

This is how my DealerModel class looks like:

[Serializable]
Public class DealerModel
{
    public string Porp1 { get; set; }
    public string Porp2 { get; set; }
    public string Porp3 { get; set; }
    public string Porp4 { get; set; }
    public string Porp5 { get; set; }
}

我猜测这个问题,有些how商Model不是被转嫁给JSON或一些东西。

Has anyone faced this issue? What could be the problem here?

这就是将我的观点转换为联合材料的方法。 服务器一侧的方法预计会列入阵列清单。

            var jsonViewModel =   ;
            jsonViewModel = ko.toJSON(myNameSpace.ViewModel1);
            jsonViewModel = jsonViewModel.replace(//Date((.*?))//gi, "new Date($1)");
            saveArray[0] = jsonViewModel

            jsonViewModel = ko.toJSON(myNameSpace.ViewModel2);
            jsonViewModel = jsonViewModel.replace(//Date((.*?))//gi, "new Date($1)");
            saveArray[1] = jsonViewModel

$.ajax({
                type: "POST",
                url: "Services/SomeService.asmx/SaveObjects",
                cache: true,
                contentType: "application/json; charset=utf-8",
                data:"{args:" + ko.toJSON(saveArray) + "}",
                dataType: "json"
            });

SaveObjects method expects arrayList.

问题回答
ko.toJSON(saveArray);

它不制造 j子。 它将生产 j子。

www.un.org/spanish/ecosoc 1. 创造香料

ko.toJS(saveArray);

注:为了对没有本地人序列仪的旧浏览器(例如,IE 7或之前)开展工作,你还必须提到

你们应该能够这样做:

        $.ajax({
            type: "POST",
            url: "Services/SomeService.asmx/SaveObjects",
            data: { args: saveArray }
        });

如果做不到这一点,你能否把你定点代码放在后面?

UPDATE I removed stuff out of your ajax post I didn t think you needed since I didn t see any callbacks with data from the server.

当你打电话ko.toJSON(myName Space.ViewModel1)时,应为ko.toJSON(myName Space.ViewModel1()。 落实你的看法模式可能正确显示你的财产。





相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签