2016-11-28 3 views
-4
{ 
    "status": "true", 
    "message": "11 records found", 
    "response": [ 
    { 
     "name": "1", 
     "address": "565400-", 
     "phone": "", 
     "gym_email": "", 
     "images": "" 
    }, 
    { 
     "name": "123", 
     "address": "102-", 
     "phone": "", 
     "gym_email": "[email protected]", 
     "images": "" 
    }, 
    { 
     "name": "Burn Gym & Spa", 
     "address": "Sector 11,HaryanaPanchkula-134101", 
     "phone": "", 
     "gym_email": "[email protected]", 
     "images": "a:1:{i:0;s:18:\"1478177269200.jpeg\";}" 
    }, 
    { 
     "name": "Burn Gym", 
     "address": "NAC,ManimajraChandigarhPanchkula-134112", 
     "phone": "", 
     "gym_email": null, 
     "images": "" 
    }, 
    { 
     "name": "Burn Gym & Spa", 
     "address": "Sector 11,ChandigarhAmbala-160101", 
     "phone": "585888", 
     "gym_email": "[email protected]", 
     "images": "" 
    }, 
    { 
     "name": "test gym", 
     "address": "Sector 11,HaryanaPanchkula-134101", 
     "phone": "0", 
     "gym_email": "[email protected]", 
     "images": "a:1:{i:1;s:17:\"1478579644341.png\";}" 
    }, 
    { 
     "name": "test gym", 
     "address": "Sector 12HaryanaPanchkula-134101", 
     "phone": "0", 
     "gym_email": "", 
     "images": "" 
    }, 
    { 
     "name": "new gym", 
     "address": "sector 11HaryanaPanchkula-134112", 
     "phone": "789654123", 
     "gym_email": "[email protected]", 
     "images": "" 
    }, 
    { 
     "name": "hrhrrth", 
     "address": "sector 11HaryanaPanchkula-134101", 
     "phone": "8054233444", 
     "gym_email": "[email protected]", 
     "images": "" 
    }, 
    { 
     "name": "hrhrrth", 
     "address": "sector 4HaryanaPanchkula-134101", 
     "phone": "0", 
     "gym_email": "", 
     "images": "" 
    }, 
    { 
     "name": "hrhrrth", 
     "address": "sector 11HaryanaPanchkula-134101", 
     "phone": "8054233444", 
     "gym_email": "[email protected]", 
     "images": "" 
    } 
    ] 
} 
당신은 같은 주소의 값을 얻을 수 있습니다
+0

이 json이 저장된 변수 및 시도한 항목은 무엇입니까? – Ali786

+2

iOS 앱에서 JSON 데이터를 구문 분석하는 수많은 예제가 있습니다. 기본적인 연구를 해주세요. 뭔가 해봐. 귀하가 시도한 내용으로 질문을 업데이트하고 현재 어떤 문제가 있는지 명확하게 설명하십시오. – rmaddy

+0

테이블보기가 있고 모든 주소의 값을 가져오고 테이블보기의 특정 셀에이 값을 설정하려고합니다. –

답변

0

addressLabel.text = [[[ mdict objectForKey : @ "응답"] valueForKey : @ "주소"] objectAtIndex : indexPath.row];

+0

여기에 "mdict"는 사전 전체 데이터가 들어 있습니다. response는 배열에 "address"라는 필드가 있고 "indexpath.row"는 배열의 인덱스 인 셀 인덱스를 나타냅니다. –

0

: 다음 루프로 응답 배열에서 주소를 얻을 수

guard let response = json["response"] as? [[String:AnyObject]] else { 
    print("Nothing here") 
    return 
} 

for data in response { 
    print(data["address"] as? String) 
} 
+0

나는 객관적인 c aakash를 사용하고있다 –

+0

@DavenderVerma 나는 Objective C에 익숙하지 않다.이 링크를 볼 수있다. http://stackoverflow.com/questions/19311899/parse-json-using-objective- c – Aakash

+0

비슷한 종류의 json 파싱이 위의 링크에서 수행되었습니다. – Aakash

0
if((jsonResult) != nil) { 
    let swiftyJsonVar = jsonResult! 
    do { 
     if let dicObj = swiftyJsonVar as? NSDictionary { 
      print("Response is dictionary") 
      print(dicObj) 
      let arrObj = dicObj["response"] as NSArray 
      // Then iterate your arrObj and do as per your need. 
      //for eg. 
      arrObj[0]["address"] 
     } 
    } 
} 
+0

sarabjit obj C를 사용하고 있습니다. –

+0

괜찮습니다 ... 나는이 코드를 객관적인 C 언어로 변경하고 당신과 공유 할 것입니다. –

+0

thx for support –

관련 문제