TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
SAXy OX is a full-featured XML and JSON marshalling framework for Objective-C. It's purpose is to allow domain objects to be serialized to XML or JSON with a minimal amount of coding.
Features include:
There are several well-documented examples in the SAXyTests folder, including:
Usage tips
As an example, given the class:
@interface CartoonCharacter : NSObject
@property(nonatomic)NSString *firstName;
@property(nonatomic)NSString *lastName;
@end
A SAXy mapper and reader can be defined in just a few lines of code:
NSString *xml = @"<tune><first>Daffy</first><last>Duck</last></tune>";
OXmlReader *reader = [OXmlReader readerWithMapper: //declares a reader with embedded mapper
[[OXmlMapper mapper] elements:@[
[OXmlElementMapper rootXPath:@"/tune" type:[CartoonCharacter class]]
,
[[[OXmlElementMapper elementClass:[CartoonCharacter class]]
xpath:@"first" property:@"firstName"]
xpath:@"last" property:@"lastName"]
]]
];
CartoonCharacter *tune = [reader readXmlText:xml]; //reads xml
STAssertEqualObjects(@"Daffy", tune.firstName, @"mapped 'first' element to 'firstName' property");
STAssertEqualObjects(@"Duck", tune.lastName, @"mapped 'last' element to 'lastName' property");