WCF サービスから JSON 文字列の応答を受信しています。この JSON をそれぞれのオブジェクトに解析したいと思います。だから私は以下のようにしました。
$.ajax({
type: 'GET',
url: 'http://URL/Service.svc/LoginValidation?',
success: function(response, status, xhr) {
if (response != "") {
var JSON=response.replace(/^"|"$/g, '\''); // replace Start and End double Quotes with single quotes. becze JSON string should be start and end with single quotes while parsing this.
var obj = JSON.parse(JSON); // Here is my problem. While accessing JSON variable here that automatically showing double quotes. so that here showing syntax error.
UserID = obj.UserID;
ClientID = obj.ClientID;
DomainName = obj.DomainName;
AuthenticationKey = obj.AuthenticationKey;
}
else {
alert("Invalid UserName or Password.");
}
}
});
この JSON データを解析する方法。JQuery を使用してこれを行うことができますか。