Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An edn implementation for Objective-C platforms (i.e. iOS, OSX).

License

NotificationsYou must be signed in to change notification settings

benmosher/edn-objc

Repository files navigation

build

A work-in-progress implementation ofedn-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/EDN 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-inuuid andinst) may be converted to concrete Cocoa objects (again,NSUUID andNSDate) via implementation of theEDNRepresentation protocol, and registering withEDNRegistry during+load. See theNSUUID+EDN andNSDate+EDN implementations for detail.

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

Objects that implement keyedNSCoding 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 intoNSDecimalNumber 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 fromNSInputStream 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, usingNSUUID for#uuid creates a dependency on iOS 6+.

##Entry points

The primary entry point isEDNSerialization, which exposes anNSJSONSerialization-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, andNSString each have an-ednObject category method that will attempt to parse the instance (returningnil on failure).NSObject defines-ednString and-ednData methods to attempt to write out the object as the root.

TheNSObject category also defines ametadata 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 asNSNull.

booleansCFBoolean (bridged withNSNumber)

  • Specifically:kCFBooleanTrue andkCFBooleanFalse.

#instNSDate

#uuidNSUUID

bonus!metadataNSDictionary

#####Custom object mappings

root (top-level)EDNRoot

listEDNList

characterEDNCharacter

symbolEDNSymbol

keywordEDNKeyword

arbitrary tags ⇌EDNTaggedElement

ratioEDNRatio

###License

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

About

An edn implementation for Objective-C platforms (i.e. iOS, OSX).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp