Giter Club home page Giter Club logo

edn-objc's Introduction

edn-objc

Update

I (Jason) have forked the project to update it. So far I have removed the deprecated features, created iOS (8+) and OSX Framework targets, and refactored and updated the test suite to use XCTest and run against the OSX framework.

A work-in-progress implementation of edn-format for Objective-C/Foundation platforms (e.g. iOS and OSX).

Current design goals are completeness and spec adherence. Any valid edn data deserialized into Cocoa/BMOEDN objects should be serialized back to the same edn UTF-8 data (barring whitespace, both in strings and amidst the edn data). This includes the 'root'; the top-level objects that are not within any root container.

Tagged elements (such as the built-in uuid and inst) may be converted to concrete Cocoa objects (again, NSUUID and NSDate) via implementation of the BMOEDNRepresentation protocol, and registering with BMOEDNRegistry during +load. See the NSUUID+BMOEDN and NSDate+BMOEDN implementations for detail.

'Unknown' tagged elements will be converted to/from BMOEDNTaggedElement during de/serialization.

Objects that implement keyed NSCoding will be written out as a map tagged with #edn-objc/[the class name]. Objects serialized this way may also be reconstituted at read time. Secure decoding is not yet supported.

Numbers are read exclusively into NSDecimalNumber and seem to afford around 128 bits of mantissa. So far, no support for arbitrary precision integers. Ratios are also supported by default, but disabled in 'strict' mode.

Lazy deserialization from NSInputStream is supported, and lazy parsing can be consumed by multiple threads using the root object's -objectEnumerator. Lazy parsing is limited to top-level objects at this time; a given object will be fully parsed into memory immediately.

Note: very little testing has occurred so far; the goal was to get a roughed-in version of reading and writing behind a decent interface out into the world. YMMV on OSX and iOS < 6.1. If you see an issue, I'd love to see a test that exposes it. Notably, using NSUUID for #uuid creates a dependency on iOS 6+.

##Entry points

The primary entry point is BMOEDNSerialization, which exposes an NSJSONSerialization-style API for parsing strings, data, or streams, as well as writing object graphs back to the same.

There are a few categories defined; NSData, NSInputStream, and NSString each have an -ednObject category method that will attempt to parse the instance (returning nil on failure). NSObject defines -ednString and -ednData methods to attempt to write out the object as the root.

The NSObject category also defines a metadata property, allowing the association of a metadata dictionary. This will be set at read time and written out at serialization time.

##Object Mapping

ednCocoa

#####'Pure' Cocoa mappings

stringNSString (surprise!)

vectorNSArray

mapNSDictionary

integer, floating pointNSDecimalNumber

setNSSet

nilNSNull

  • nil is also written out for nil/NULL pointers, but currently read in as NSNull.

booleansCFBoolean (bridged with NSNumber)

  • Specifically: kCFBooleanTrue and kCFBooleanFalse.

#instNSDate

#uuidNSUUID

bonus! metadataNSDictionary

#####Custom object mappings

root (top-level) BMOEDNRoot

listBMOEDNList

characterBMOEDNCharacter

symbolBMOEDNSymbol

keywordBMOEDNKeyword

arbitrary tags ⇌ BMOEDNTaggedElement

ratioBMOEDNRatio

###License

This project is licensed under the Eclipse Public License, v1.

edn-objc's People

Contributors

arohner avatar benmosher avatar kraag22 avatar

Watchers

 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.