gpt4 book ai didi

ios - JSONKit : create a json formatted string

转载 作者:可可西里 更新时间:2023-11-01 04:21:46 24 4
gpt4 key购买 nike

我想将 NSDictionary 和 NSArrays 转换为 json 格式。 JSON Kit 能做到吗?如何做到?

最佳答案

//数据->字符串

NSMutableDictionary *nameElements = [NSMutableDictionary dictionary];     

[nameElements setObject:@"abcd" forKey:@"username"];

[nameElements setObject:@"1234" forKey:@"password"];

NSString* jsonString = [nameElements JSONString];

//字符串->数据

NSDictionary *nameElements_ = [jsonString objectFromJSONString];   

for(NSString *key in [nameElements_ allKeys]) {
NSString* body = [nameElements_ objectForKey:key];
NSLog(@"%@", body);
}

关于ios - JSONKit : create a json formatted string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6736137/

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