Git Product home page Git Product logo

saxy's Introduction

SAXy OX - Objective-C XML and JSON Binding Library

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:

  • efficient reading/unmarshalling and writing/marshalling of XML or JSON from domain objects
  • full XML namespace support
  • built-in type conversion and formatting
  • highly configurable API
  • modern Objective-C: ARC and blocks
  • self-reflective automatic mapping
  • optimized for iOS with no no third-party dependencies

There are several well-documented examples in the SAXyTests folder, including:

Usage tips

  • run the examples (Product->Test in Xcode), set break points to inspect state
  • watch the mapper in action by setting: reader.context.logReaderStack = YES;
  • create your own mapping by starting with a working example and making small modifications
  • the JSON or XML folder can be removed if not being used

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");

saxy's People

Contributors

reaster avatar mikenicholson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.