次のようなクラスのリストがあります。
@interface AISlideItem: NSObject
{
NSString* PlaceHolderName;
NSUInteger PlaceHolderID;
}
@property (nonatomic, strong) NSString* PlaceHolderName;
@property (nonatomic) NSUInteger PlaceHolderID;
@end
@interface AITitleSlideItem : AISlideItem
{
NSString* Title;
}
@property (nonatomic, strong) NSString* Title;
@end
@interface AIParagraphSlideItem : AISlideItem
{
NSMutableArray* Paragraphs;
}
@property (nonatomic, strong) NSMutableArray* Paragraphs;
@end
@interface AITextSlideItem : AISlideItem
{
NSString* Text;
}
@property (nonatomic, strong) NSString* Text;
@end
@interface AIPictureSlideItem : AISlideItem
{
NSMutableData* Picture;
}
@property (nonatomic, strong) NSMutableData* Picture;
@end
@interface AISlideContent : NSObject
{
NSString* LayoutName;
NSMutableArray* Items;
}
@property (nonatomic,strong) NSString* LayoutName;
@property (nonatomic,strong) NSMutableArray* Items;
@end
@interface ContentParaghraph : NSObject
{
NSInteger Level;
NSString* Text;
}
@property (nonatomic) NSInteger Level;
@property (nonatomic, strong) NSString* Text;
@end
AISlideContent オブジェクトを保持する NSMutableArray を json にシリアル化したいです。json 内のすべての項目の名前は、変数の名前と同じにする必要があります。
どうやってやるの?
これは JSON の例です。
{
d: [
{
Items: [
{
placeHolderName: "1",
Title: "Title Slide"
},
{
placeHolderName: "2",
Paragraphs: [
{
Level: 0,
Text: "Title content"
}
]
}
],
LayoutName: "Title"
},
{
Items: [
{
placeHolderName: "1",
Title: "Slide 2"
},
{
placeHolderName: "2",
Paragraphs: [
{
Level: 0,
Text: "Line 1"
},
{
Level: 0,
Text: "Line 2"
},
{
Level: 1,
Text: "Line 2 indented"
},
{
Level: 2,
Text: "Line 3 more indented"
},
{
Level: 0,
Text: "Line 4"
}
]
}
],
LayoutName: "Title and Content"
},
{
Items: [
{
placeHolderName: "1",
Title: "Slide 3"
},
{
placeHolderName: "3",
Picture: [
]
}
],
LayoutName: "Picture above Caption"
}
]
}
ps私はARCを有効にしています