栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SBJsonWriter嵌套NSDictionary

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SBJsonWriter嵌套NSDictionary

在JSON中,

{ }
代表一个对象(键/值对)并
[ ]
代表一个数组。从您提供的示例来看,这是服务器的期望值:

最高对象 :具有两个键的字典:

TypeProperties
ImageUrls

TypePropertiesImageUrls
:每个数组都是一个包含一个或多个带有两个键的对象的数组:

Key
Value
。每个键应具有其各自的值。

为了符合服务器的期望,您需要一个与此类似的结构(请注意,这只是一个简单的示例,直接在此处编写,但应指出正确的方向):

NSDictionary *object = [NSDictionary dictionaryWithObjectsAndKeys:  @"prop 0", @"Key",  @"blah 0", @"Value",  nil];NSArray *typeProperties = [NSArray arrayWithObjects:     object, // Add as many similar objects as you want     nil];NSArray *imageUrls = [NSArray arrayWithObjects:object, // Add as many similar objects as you wantnil];

然后,在您的

proxyForJson
方法中,您可以使用:

- (NSDictionary*) proxyForJson{      return [NSDictionary dictionaryWithObjectsAndKeys:   typeProperties, @"TypeProperties",   imageUrls, @"ImageUrls",   nil];}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/383509.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号