gpt4 book ai didi

ios - JSON iOS 解析字符串

转载 作者:行者123 更新时间:2023-11-29 11:22:47 25 4
gpt4 key购买 nike

{"response":[33689822,64091979,69682048,74160161]}

-

- (void)requestCompleted:(ASIHTTPRequest *)request
{
NSString *responseString = [request responseString];
NSLog(@"okRequest|| %@",responseString);

SBJSON *parser = [[SBJSON alloc] init];

// Prepare URL request to download statuses from Twitter

// Get JSON as a NSString from NSData response
NSString *json_string = [[NSString alloc] initWithString:responseString];

// parse the JSON response into an object
// Here we're using NSArray since we're parsing an array of JSON status objects
NSArray *statuses = [parser objectWithString:json_string error:nil];

// Each element in statuses is a single status
// represented as a NSDictionary
for (NSDictionary *status in statuses)
{
//all other func..
NSLog(@"%@ ", status);///This func prints only "response"
}
}

如何在“响应”中获取数字数组? (33689822,64091979,69682048,74160161)

最佳答案

试试这个:

for (NSNumber *number in [statuses objectForKey:@"response"]) {
NSLog(@"%@", number);
}

关于ios - JSON iOS 解析字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6055049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com