0
전 Objective-C 프로그래밍에서 완전히 새롭습니다.Objective-c 구문 분석 JSON
내 앱에서 요청을 받으려고합니다. Objective-C에 Unirest를 HTTP 라이브러리로 사용하고 있습니다.
내 API는 다음과 JSON을 반환합니다 : - 당신이 body.JSONObject [@ "상태"]를 참조로
{
"merchant_list": [
{
"_id": "543ce2887ca4e102af44a5a8",
"address": "MyAddress bla bla bla",
"admin": [
"543ce2887ca4e102af44a5a7"
],
"card": null,
"circle": null,
"dollar_ratio": null,
"fb": null,
"logo": null,
"min_spending_VIP": null,
"modification_timestamp_utc": 1413276296.0,
"name": "Lorem ipsum",
"outlets": [],
"promotions": [],
"referral_ratio": null
}
],
"status": "ok"
}
Unirest 라이브러리 나 "확인"값을 줄 것이다 NSDictionary에 나있는 NSArray이 JSON을 구문 분석 할 수 있습니다.
하지만 문제는 merchant_list의 모든 속성에 액세스 할 수 없다는 것입니다. 아래 merchant_list의
UNIJsonNode *body = response.body;
if ([body.JSONObject[@"status"] isEqualToString:@"ok"])
{
NSLog(@"%@", body.JSONObject[@"merchant_list"]);
}
NSLog 값 : -
2014-10-17 18:07:10.623 MyApp[18567:287513] (
{
"_id" = 543ce2887ca4e102af44a5a8;
address = "MyAddress bla bla bla";
admin = (
543ce2887ca4e102af44a5a7
);
card = "<null>";
circle = "<null>";
"dollar_ratio" = "<null>";
fb = "<null>";
logo = "<null>";
"min_spending_VIP" = "<null>";
"modification_timestamp_utc" = 1413276296;
name = "Lorem ipsum";
outlets = (
);
promotions = (
);
"referral_ratio" = "<null>";
}
)
어떤 도움? 나는 이미이 오류 때문에 몇 시간을 보냈다.
사용이 LIB : https://github.com/AFNetworking/AFNetworking –
속성을 사용하면 액세스 할 수 있습니까? 입력 된 JSON과 일치하는 것처럼 로그가 표시됩니다. – Keab42
@SandroMachado는 그것을 살펴볼 것입니다. – skycrew