JSON Objective

编程入门 行业动态 更新时间:2024-10-27 06:19:54
JSON Objective-c - 对象和数组组合(JSON Objective-c - Objects and Arrays Combination)

我的JSON网址是 http://api.kivaws.org/v1/loans/search.json?status=fundraising

我的目标代码使用以下代码显示page_size:20

NSData *allCourseData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]]; NSError *error; NSMutableDictionary *JsonObject = [NSJSONSerialization JSONObjectWithData:allCourseData options:NSJSONReadingMutableContainers error:&error]; //NSLog(@"json object is: - %@", JsonObject); //Print Page size NSLog(@"Page size is %@", [[JsonObject objectForKey:@"paging"] objectForKey:@"page_size"]);

我的问题是如何循环到Loans数组以显示以下示例它将显示名称,显示所有语言,状态因此输出将看起来像 ============================ 姓名:“Maria Luisa” 语言:es,en 状态:“筹款” 部门:“零售” 位置

country_code:“NI”

名称:“佛罗伦萨”语言:en 状态:“筹款” 部门:“零售” 位置 country_code:“KE”

MyJSON Feed

{ "paging": { "page": 1, "total": 7279, "page_size": 20, "pages": 364 }, "loans": [ { "id": 941933, "name": "Maria Luisa", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969857, "template_id": 1 }, "activity": "General Store", "sector": "Retail", "use": "to buy rice, chicken, sausages, corn, beans, and sugar.", "location": { "country_code": "NI", "country": "Nicaragua", "town": "Esteli", "geo": { "level": "town", "pairs": "13.166667 -86.333333", "type": "point" } }, "partner_id": 176, "posted_date": "2015-09-04T09:20:02Z", "planned_expiration_date": "2015-10-04T09:20:02Z", "loan_amount": 600, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942181, "name": "Florence", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970181, "template_id": 1 }, "activity": "Retail", "sector": "Retail", "use": "to buy more stocks of maize.", "location": { "country_code": "KE", "country": "Kenya", "town": "Bondo", "geo": { "level": "town", "pairs": "1 38", "type": "point" } }, "partner_id": 138, "posted_date": "2015-09-04T09:10:08Z", "planned_expiration_date": "2015-10-04T09:10:08Z", "loan_amount": 200, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942146, "name": "Naziha", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970129, "template_id": 1 }, "activity": "Fruits & Vegetables", "sector": "Food", "use": "to increase her merchandise and diversify the products in her shop.", "location": { "country_code": "LB", "country": "Lebanon", "town": "Ain Al Helwi", "geo": { "level": "town", "pairs": "33.833333 35.833333", "type": "point" } }, "partner_id": 77, "posted_date": "2015-09-04T09:10:02Z", "planned_expiration_date": "2015-10-04T09:10:02Z", "loan_amount": 2500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942180, "name": "Sokean's Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970180, "template_id": 1 }, "activity": "Home Appliances", "sector": "Personal Use", "themes": [ "Water and Sanitation" ], "use": "to buy a water filter to provide safe drinking water for her family.", "location": { "country_code": "KH", "country": "Cambodia", "town": "Kandal", "geo": { "level": "town", "pairs": "13 105", "type": "point" } }, "partner_id": 311, "posted_date": "2015-09-04T09:00:05Z", "planned_expiration_date": "2015-10-04T09:00:05Z", "loan_amount": 100, "borrower_count": 2, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [ { "name": "volunteer_like" } ] }, { "id": 941931, "name": "Lucia Ingrid", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969852, "template_id": 1 }, "activity": "Personal Housing Expenses", "sector": "Housing", "themes": [ "Conflict Zones" ], "use": "to invest in: electric wires, a fuse box, sockets, and labor to install electricity in her home.", "location": { "country_code": "SV", "country": "El Salvador", "geo": { "level": "country", "pairs": "13.833333 -88.916667", "type": "point" } }, "partner_id": 81, "posted_date": "2015-09-04T09:00:03Z", "planned_expiration_date": "2015-10-04T09:00:03Z", "loan_amount": 500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 941930, "name": "La Manzanita Group", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969849, "template_id": 1 }, "activity": "Fruits & Vegetables", "sector": "Food", "use": "to invest in buying papayas and nance berries in bulk.", "location": { "country_code": "NI", "country": "Nicaragua", "town": "Masaya", "geo": { "level": "town", "pairs": "11.966667 -86.1", "type": "point" } }, "partner_id": 120, "posted_date": "2015-09-04T08:50:02Z", "planned_expiration_date": "2015-10-04T08:50:02Z", "loan_amount": 450, "borrower_count": 3, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 941926, "name": "Manuel", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969843, "template_id": 1 }, "activity": "Property", "sector": "Housing", "use": "to buy two acres of land.", "location": { "country_code": "GT", "country": "Guatemala", "town": "Solola", "geo": { "level": "town", "pairs": "14.666667 -91.25", "type": "point" } }, "partner_id": 246, "posted_date": "2015-09-04T08:10:02Z", "planned_expiration_date": "2015-10-04T08:10:02Z", "loan_amount": 800, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [ { "name": "volunteer_like" } ] }, { "id": 942158, "name": "Tahira", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 150, "basket_amount": 0, "image": { "id": 1969161, "template_id": 1 }, "activity": "Sewing", "sector": "Services", "themes": [ "Underfunded Areas" ], "use": "buy a new sewing machine for her clothes sewing center.", "location": { "country_code": "PK", "country": "Pakistan", "town": "Multan", "geo": { "level": "town", "pairs": "30.195556 71.475278", "type": "point" } }, "partner_id": 247, "posted_date": "2015-09-04T07:00:05Z", "planned_expiration_date": "2015-10-04T07:00:05Z", "loan_amount": 400, "borrower_count": 1, "lender_count": 5, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942166, "name": "Sareoun's Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970161, "template_id": 1 }, "activity": "Home Appliances", "sector": "Personal Use", "themes": [ "Water and Sanitation" ], "use": "to buy a water filter to provide safe drinking water for their family.\t.", "location": { "country_code": "KH", "country": "Cambodia", "town": "Kandal", "geo": { "level": "town", "pairs": "13 105", "type": "point" } }, "partner_id": 311, "posted_date": "2015-09-04T07:00:05Z", "planned_expiration_date": "2015-10-04T07:00:05Z", "loan_amount": 225, "borrower_count": 5, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942156, "name": "Aiza", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 75, "basket_amount": 0, "image": { "id": 1970147, "template_id": 1 }, "activity": "Farming", "sector": "Agriculture", "use": "to buy fertilizers and other farm supplies", "location": { "country_code": "PH", "country": "Philippines", "town": "Kalibo, Aklan", "geo": { "level": "town", "pairs": "13 122", "type": "point" } }, "partner_id": 145, "posted_date": "2015-09-04T07:00:03Z", "planned_expiration_date": "2015-10-04T07:00:03Z", "loan_amount": 225, "borrower_count": 1, "lender_count": 2, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942160, "name": "Magu Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970122, "template_id": 1 }, "activity": "Used Clothing", "sector": "Clothing", "use": "to buy fast moving second hand clothes to meet her customer requirement.", "location": { "country_code": "TZ", "country": "Tanzania", "town": "Dar es Salaam", "geo": { "level": "town", "pairs": "-6.8 39.283333", "type": "point" } }, "partner_id": 87, "posted_date": "2015-09-04T07:00:02Z", "planned_expiration_date": "2015-10-04T07:00:02Z", "loan_amount": 525, "borrower_count": 2, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942142, "name": "Mwanamiraji", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970130, "template_id": 1 }, "activity": "Food Stall", "sector": "Food", "use": "to purchase a stock of tomatoes, onions, mangoes and green vegetables for resale", "location": { "country_code": "KE", "country": "Kenya", "town": "Tiribe", "geo": { "level": "town", "pairs": "1 38", "type": "point" } }, "partner_id": 164, "posted_date": "2015-09-04T06:30:04Z", "planned_expiration_date": "2015-10-04T06:30:04Z", "loan_amount": 200, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 940065, "name": "Tubogorane Group", "description": { "languages": [ "fr", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1967147, "template_id": 1 }, "activity": "Food", "sector": "Food", "themes": [ "Conflict Zones" ], "use": "to increase his working capital and buy a large quantity of fruit and cheese for sale.", "location": { "country_code": "BI", "country": "Burundi", "town": "Bujumbura", "geo": { "level": "town", "pairs": "-3.5 30", "type": "point" } }, "partner_id": 162, "posted_date": "2015-09-04T06:20:05Z", "planned_expiration_date": "2015-10-04T06:20:05Z", "loan_amount": 3050, "borrower_count": 19, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [] }, { "id": 940076, "name": "Wend Loiim Taore 2 Group", "description": { "languages": [ "fr", "en" ] }, "status": "fundraising", "funded_amount": 50, "basket_amount": 0, "image": { "id": 1967173, "template_id": 1 }, "activity": "Clothing Sales", "sector": "Clothing", "use": "to buy pagnes (traditional, wrap-around clothing) and soap for sale.", "location": { "country_code": "BF", "country": "Burkina Faso", "town": "Ouagadougou Boulmiougou", "geo": { "level": "town", "pairs": "13 -2", "type": "point" } }, "partner_id": 398, "posted_date": "2015-09-04T06:20:05Z", "planned_expiration_date": "2015-10-04T06:20:05Z", "loan_amount": 1850, "borrower_count": 5, "lender_count": 2, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942145, "name": "Adham", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 25, "basket_amount": 0, "image": { "id": 1970127, "template_id": 1 }, "activity": "Barber Shop", "sector": "Services", "use": "to buy new salon equipment.", "location": { "country_code": "PS", "country": "Palestine", "town": "Bethlehem", "geo": { "level": "town", "pairs": "31.92157 35.203285", "type": "point" } }, "partner_id": 289, "posted_date": "2015-09-04T06:10:04Z", "planned_expiration_date": "2015-10-04T06:10:04Z", "loan_amount": 3000, "borrower_count": 1, "lender_count": 2, "bonus_credit_eligibility": false, "tags": [ { "name": "user_favorite" } ] }, { "id": 941929, "name": "Silvia Yesenia", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969848, "template_id": 1 }, "activity": "Retail", "sector": "Retail", "themes": [ "Conflict Zones" ], "use": " to buy vegetables, legumes, staple grains and meat, amongst other items, to offer a better service to her customers", "location": { "country_code": "SV", "country": "El Salvador", "geo": { "level": "country", "pairs": "13.833333 -88.916667", "type": "point" } }, "partner_id": 81, "posted_date": "2015-09-04T06:10:03Z", "planned_expiration_date": "2015-10-04T06:10:03Z", "loan_amount": 500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] } ] }

My JSON url is http://api.kivaws.org/v1/loans/search.json?status=fundraising

My Objective- code displays page_size : 20 using the following code

NSData *allCourseData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]]; NSError *error; NSMutableDictionary *JsonObject = [NSJSONSerialization JSONObjectWithData:allCourseData options:NSJSONReadingMutableContainers error:&error]; //NSLog(@"json object is: - %@", JsonObject); //Print Page size NSLog(@"Page size is %@", [[JsonObject objectForKey:@"paging"] objectForKey:@"page_size"]);

My problem is how do i loop to Loans array to display the following Example it will display name, display ALL languages, status so output will look like ============================ Name : "Maria Luisa" languages: es,en status : "fundraising" sector : "Retail" location

country_code : "NI"

Name : "Florence" languages: en status : "fundraising" sector : "Retail" location country_code : "KE"

MyJSON Feed

{ "paging": { "page": 1, "total": 7279, "page_size": 20, "pages": 364 }, "loans": [ { "id": 941933, "name": "Maria Luisa", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969857, "template_id": 1 }, "activity": "General Store", "sector": "Retail", "use": "to buy rice, chicken, sausages, corn, beans, and sugar.", "location": { "country_code": "NI", "country": "Nicaragua", "town": "Esteli", "geo": { "level": "town", "pairs": "13.166667 -86.333333", "type": "point" } }, "partner_id": 176, "posted_date": "2015-09-04T09:20:02Z", "planned_expiration_date": "2015-10-04T09:20:02Z", "loan_amount": 600, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942181, "name": "Florence", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970181, "template_id": 1 }, "activity": "Retail", "sector": "Retail", "use": "to buy more stocks of maize.", "location": { "country_code": "KE", "country": "Kenya", "town": "Bondo", "geo": { "level": "town", "pairs": "1 38", "type": "point" } }, "partner_id": 138, "posted_date": "2015-09-04T09:10:08Z", "planned_expiration_date": "2015-10-04T09:10:08Z", "loan_amount": 200, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942146, "name": "Naziha", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970129, "template_id": 1 }, "activity": "Fruits & Vegetables", "sector": "Food", "use": "to increase her merchandise and diversify the products in her shop.", "location": { "country_code": "LB", "country": "Lebanon", "town": "Ain Al Helwi", "geo": { "level": "town", "pairs": "33.833333 35.833333", "type": "point" } }, "partner_id": 77, "posted_date": "2015-09-04T09:10:02Z", "planned_expiration_date": "2015-10-04T09:10:02Z", "loan_amount": 2500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942180, "name": "Sokean's Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970180, "template_id": 1 }, "activity": "Home Appliances", "sector": "Personal Use", "themes": [ "Water and Sanitation" ], "use": "to buy a water filter to provide safe drinking water for her family.", "location": { "country_code": "KH", "country": "Cambodia", "town": "Kandal", "geo": { "level": "town", "pairs": "13 105", "type": "point" } }, "partner_id": 311, "posted_date": "2015-09-04T09:00:05Z", "planned_expiration_date": "2015-10-04T09:00:05Z", "loan_amount": 100, "borrower_count": 2, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [ { "name": "volunteer_like" } ] }, { "id": 941931, "name": "Lucia Ingrid", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969852, "template_id": 1 }, "activity": "Personal Housing Expenses", "sector": "Housing", "themes": [ "Conflict Zones" ], "use": "to invest in: electric wires, a fuse box, sockets, and labor to install electricity in her home.", "location": { "country_code": "SV", "country": "El Salvador", "geo": { "level": "country", "pairs": "13.833333 -88.916667", "type": "point" } }, "partner_id": 81, "posted_date": "2015-09-04T09:00:03Z", "planned_expiration_date": "2015-10-04T09:00:03Z", "loan_amount": 500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 941930, "name": "La Manzanita Group", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969849, "template_id": 1 }, "activity": "Fruits & Vegetables", "sector": "Food", "use": "to invest in buying papayas and nance berries in bulk.", "location": { "country_code": "NI", "country": "Nicaragua", "town": "Masaya", "geo": { "level": "town", "pairs": "11.966667 -86.1", "type": "point" } }, "partner_id": 120, "posted_date": "2015-09-04T08:50:02Z", "planned_expiration_date": "2015-10-04T08:50:02Z", "loan_amount": 450, "borrower_count": 3, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 941926, "name": "Manuel", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969843, "template_id": 1 }, "activity": "Property", "sector": "Housing", "use": "to buy two acres of land.", "location": { "country_code": "GT", "country": "Guatemala", "town": "Solola", "geo": { "level": "town", "pairs": "14.666667 -91.25", "type": "point" } }, "partner_id": 246, "posted_date": "2015-09-04T08:10:02Z", "planned_expiration_date": "2015-10-04T08:10:02Z", "loan_amount": 800, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [ { "name": "volunteer_like" } ] }, { "id": 942158, "name": "Tahira", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 150, "basket_amount": 0, "image": { "id": 1969161, "template_id": 1 }, "activity": "Sewing", "sector": "Services", "themes": [ "Underfunded Areas" ], "use": "buy a new sewing machine for her clothes sewing center.", "location": { "country_code": "PK", "country": "Pakistan", "town": "Multan", "geo": { "level": "town", "pairs": "30.195556 71.475278", "type": "point" } }, "partner_id": 247, "posted_date": "2015-09-04T07:00:05Z", "planned_expiration_date": "2015-10-04T07:00:05Z", "loan_amount": 400, "borrower_count": 1, "lender_count": 5, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942166, "name": "Sareoun's Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970161, "template_id": 1 }, "activity": "Home Appliances", "sector": "Personal Use", "themes": [ "Water and Sanitation" ], "use": "to buy a water filter to provide safe drinking water for their family.\t.", "location": { "country_code": "KH", "country": "Cambodia", "town": "Kandal", "geo": { "level": "town", "pairs": "13 105", "type": "point" } }, "partner_id": 311, "posted_date": "2015-09-04T07:00:05Z", "planned_expiration_date": "2015-10-04T07:00:05Z", "loan_amount": 225, "borrower_count": 5, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942156, "name": "Aiza", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 75, "basket_amount": 0, "image": { "id": 1970147, "template_id": 1 }, "activity": "Farming", "sector": "Agriculture", "use": "to buy fertilizers and other farm supplies", "location": { "country_code": "PH", "country": "Philippines", "town": "Kalibo, Aklan", "geo": { "level": "town", "pairs": "13 122", "type": "point" } }, "partner_id": 145, "posted_date": "2015-09-04T07:00:03Z", "planned_expiration_date": "2015-10-04T07:00:03Z", "loan_amount": 225, "borrower_count": 1, "lender_count": 2, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942160, "name": "Magu Group", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970122, "template_id": 1 }, "activity": "Used Clothing", "sector": "Clothing", "use": "to buy fast moving second hand clothes to meet her customer requirement.", "location": { "country_code": "TZ", "country": "Tanzania", "town": "Dar es Salaam", "geo": { "level": "town", "pairs": "-6.8 39.283333", "type": "point" } }, "partner_id": 87, "posted_date": "2015-09-04T07:00:02Z", "planned_expiration_date": "2015-10-04T07:00:02Z", "loan_amount": 525, "borrower_count": 2, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 942142, "name": "Mwanamiraji", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1970130, "template_id": 1 }, "activity": "Food Stall", "sector": "Food", "use": "to purchase a stock of tomatoes, onions, mangoes and green vegetables for resale", "location": { "country_code": "KE", "country": "Kenya", "town": "Tiribe", "geo": { "level": "town", "pairs": "1 38", "type": "point" } }, "partner_id": 164, "posted_date": "2015-09-04T06:30:04Z", "planned_expiration_date": "2015-10-04T06:30:04Z", "loan_amount": 200, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] }, { "id": 940065, "name": "Tubogorane Group", "description": { "languages": [ "fr", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1967147, "template_id": 1 }, "activity": "Food", "sector": "Food", "themes": [ "Conflict Zones" ], "use": "to increase his working capital and buy a large quantity of fruit and cheese for sale.", "location": { "country_code": "BI", "country": "Burundi", "town": "Bujumbura", "geo": { "level": "town", "pairs": "-3.5 30", "type": "point" } }, "partner_id": 162, "posted_date": "2015-09-04T06:20:05Z", "planned_expiration_date": "2015-10-04T06:20:05Z", "loan_amount": 3050, "borrower_count": 19, "lender_count": 0, "bonus_credit_eligibility": false, "tags": [] }, { "id": 940076, "name": "Wend Loiim Taore 2 Group", "description": { "languages": [ "fr", "en" ] }, "status": "fundraising", "funded_amount": 50, "basket_amount": 0, "image": { "id": 1967173, "template_id": 1 }, "activity": "Clothing Sales", "sector": "Clothing", "use": "to buy pagnes (traditional, wrap-around clothing) and soap for sale.", "location": { "country_code": "BF", "country": "Burkina Faso", "town": "Ouagadougou Boulmiougou", "geo": { "level": "town", "pairs": "13 -2", "type": "point" } }, "partner_id": 398, "posted_date": "2015-09-04T06:20:05Z", "planned_expiration_date": "2015-10-04T06:20:05Z", "loan_amount": 1850, "borrower_count": 5, "lender_count": 2, "bonus_credit_eligibility": false, "tags": [] }, { "id": 942145, "name": "Adham", "description": { "languages": [ "en" ] }, "status": "fundraising", "funded_amount": 25, "basket_amount": 0, "image": { "id": 1970127, "template_id": 1 }, "activity": "Barber Shop", "sector": "Services", "use": "to buy new salon equipment.", "location": { "country_code": "PS", "country": "Palestine", "town": "Bethlehem", "geo": { "level": "town", "pairs": "31.92157 35.203285", "type": "point" } }, "partner_id": 289, "posted_date": "2015-09-04T06:10:04Z", "planned_expiration_date": "2015-10-04T06:10:04Z", "loan_amount": 3000, "borrower_count": 1, "lender_count": 2, "bonus_credit_eligibility": false, "tags": [ { "name": "user_favorite" } ] }, { "id": 941929, "name": "Silvia Yesenia", "description": { "languages": [ "es", "en" ] }, "status": "fundraising", "funded_amount": 0, "basket_amount": 0, "image": { "id": 1969848, "template_id": 1 }, "activity": "Retail", "sector": "Retail", "themes": [ "Conflict Zones" ], "use": " to buy vegetables, legumes, staple grains and meat, amongst other items, to offer a better service to her customers", "location": { "country_code": "SV", "country": "El Salvador", "geo": { "level": "country", "pairs": "13.833333 -88.916667", "type": "point" } }, "partner_id": 81, "posted_date": "2015-09-04T06:10:03Z", "planned_expiration_date": "2015-10-04T06:10:03Z", "loan_amount": 500, "borrower_count": 1, "lender_count": 0, "bonus_credit_eligibility": true, "tags": [] } ] }

最满意答案

loans数组是在顶级JSON对象中,因此:

NSArray *loans = jsonObject[@"loans"]; for (NSDictionary *loan in loans) { NSNumber *ident = loan[@"id"]; NSString *name = loan[@"name"]; NSDictionary *description = loan[@"description"]; NSDictionary *location = loan[@"location"]; NSString *country = location[@"country"]; // etc. }

Well the loans array is in the top-level JSON object, so:

NSArray *loans = jsonObject[@"loans"]; for (NSDictionary *loan in loans) { NSNumber *ident = loan[@"id"]; NSString *name = loan[@"name"]; NSDictionary *description = loan[@"description"]; NSDictionary *location = loan[@"location"]; NSString *country = location[@"country"]; // etc. }

更多推荐

本文发布于:2023-08-07 06:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JSON   Objective

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!