1

我从我的 WS 请求中从 jquery 得到这个响应。

{
    "SkyWinResponse": {
        "statuscode": 0,
        "message": "ok\n ",
        "rowsaffected": 1,
        "results": {
            "result": {
                "@xsi.type": "member",
                "accountCreditLimit": 0,
                "accountNo": 1000001,
                "address1": "Annavägen 10",
                "addressChangeDate": "2013-04-12",
                "balance": 2068,
                "balanceCurrency": "kr",
                "certificateText": "PK",
                "climateCompensate": 2,
                "club": "UFK",
                "contactName": "Last, Andreas",
                "contactPhone": "090-123456",
                "countryCode": "SE",
                "countryNameLocalized": "Sverige",
                "createdDate": "2013-04-11",
                "credit": false,
                "dateOfBirth": "1971-05-04",
                "emailAddress": "first.last@ufk.nu",
                "firstJumpDate": "2013-04-27",
                "firstName": "First",
                "gender": "M",
                "hideAccountInRequest": false,
                "honorary": false,
                "infoViaEmail": true,
                "instructorText": "HL HM KL",
                "internalNo": 1,
                "jumpNo": 0,
                "lastName": "Nylund",
                "lastUpd": "2013-05-18 15:58:23.0",
                "licenseType": "C",
                "markedForLabel": false,
                "memberList": false,
                "memberListOverride": true,
                "memberNo": 20878,
                "memberType": "M",
                "nationalityCode": "SE",
                "nationalityNameLocalized": "Sverige",
                "permanentCredit": false,
                "pilot": false,
                "postCode": 91342,
                "postTown": "Obbola",
                "studentJumpNo": 0,
                "supporter": false,
                "userId": "Linda",
                "verifiedLicense": true,
                "video": false,
                "weight": 100,
                "weightUnit": "kg",
                "year": 2013
            }
        }
    }
}

但是当我尝试解析这个时,我只会得到无效的标签。任何关于如何读取每个条目 entry:value 并将它们显示在 html 页面中的建议。

这是我试图运行的代码。

$(document).ready(function(){ $.ajax({ url: ' http://fake.server.se/skywin-ws-1.4.0/rest/skywin/member/getMember?memberNo=20878&_type=json ', dataType: 'jsonp', 成功: function(SkyWinResponse){ $.each(data.SkyWinResponse.results.result, function(i, item) { $('#response').append(i + " : " +项目 + "
"); }); } }); })

4

1 回答 1

0

看来您的 JSON 是有效的。你是否试图做这样的事情:

 $.each(data.SkyWinResponse.results.result, function(i, item)
 {
     $('#response').append(i + " : " + item + "<br>");
 });

JSFiddle

于 2013-05-21T13:15:57.147 回答