2014-01-14 6 views
0

안녕하세요, JSON을 통해 웹 API에서 데이터를 가져 오려고합니다. 이 우리 JSON 객체가 모습입니다 같은 :웹 API에서 JSON 가져 오기 ASP.NET C#

링크 : 방법에

function Get_5Messages() 


{ 
      $.getJSON(
        'Link', 
        function (data) { 
         for (var k = 0; k < data.result.length; k++) { 
          $('#div_Meddelande').text("Kontoret nedstängt" + data[i].Get_Meddelande); 
         } 
        } 
     ); 
     } 

어떤 제안이 우리의 JSON 호출이 http://localhost:51437/api/values

<ArrayOfMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Entities"> 
<Message> 
<Get_Avsändare>0</Get_Avsändare> 
<Get_Datum>2012-12-14 12:12:12</Get_Datum> 
<Get_Meddelande>hejsan</Get_Meddelande> 
<Get_Mottagare>0</Get_Mottagare> 
<Get_Savsändare i:nil="true"/> 
<Get_Smottagare>Hanna</Get_Smottagare> 
</Message> 
<Message> 
<Get_Avsändare>0</Get_Avsändare> 
<Get_Datum>2012-12-14 12:12:12</Get_Datum> 
<Get_Meddelande>svejassa</Get_Meddelande> 
<Get_Mottagare>0</Get_Mottagare> 
<Get_Savsändare i:nil="true"/> 
<Get_Smottagare>Hanna</Get_Smottagare> 
</Message> 
<Message> 
<Get_Avsändare>0</Get_Avsändare> 
<Get_Datum>2012-12-14 12:12:12</Get_Datum> 
<Get_Meddelande>lalala</Get_Meddelande> 
<Get_Mottagare>0</Get_Mottagare> 
<Get_Savsändare i:nil="true"/> 
<Get_Smottagare>Hanna</Get_Smottagare> 
</Message> 
<Message> 
<Get_Avsändare>0</Get_Avsändare> 
<Get_Datum>2012-12-14 12:12:12</Get_Datum> 
<Get_Meddelande>hejsan</Get_Meddelande> 
<Get_Mottagare>0</Get_Mottagare> 
<Get_Savsändare i:nil="true"/> 
<Get_Smottagare>Hanna</Get_Smottagare> 
</Message> 
<Message> 
<Get_Avsändare>0</Get_Avsändare> 
<Get_Datum>2012-12-14 12:12:12</Get_Datum> 
<Get_Meddelande>svejassa</Get_Meddelande> 
<Get_Mottagare>0</Get_Mottagare> 
<Get_Savsändare i:nil="true"/> 
<Get_Smottagare>Hanna</Get_Smottagare> 
</Message> 
</ArrayOfMessage> 

입니다 이 문제를 해결 하시겠습니까? Google 검색을 도와주세요.하지만 답변을 찾을 수 없습니다.

+1

JSON이 아니며 XML입니다. – dherman

+0

질문에 넣은 "JSON"은 실제로 문제 번호 1 일 수있는 XML입니다. 잘못된 데이터 형식을 다시 브라우저로 반환하고 있습니다. 둘째로, 귀하가 올린 링크는 귀하의 컴퓨터 인 localhost입니다. 아무도 그 링크를 볼 수 있지만 너. –

답변

0

안녕하세요.

당신은 우리에게 다음과 같은 것이 같을 것이다 XML 문서가 아닌 JSON 응답을 보여 주었다 :

{ 
    title: "Title data", 
    message: "Message data", 
    tags: [ 
     "tag","tag","tag" 
    ] 
} 

XML 문서 (API를 정말)을 구문 분석을, 당신은 jQuery's xml parser를 활용한다

관련 문제