You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -9,16 +9,16 @@ A library for loading data from a [JSON API](http://jsonapi.org) datasource. Par
9
9
10
10
Version | Changes
11
11
--- | ---
12
+
**1.0.0** | We did it team! Resources now use `JSONAPIResourceDescriptor` for more explicit definitions. **HUGE** thanks to [jkarmstr](https://github.com/jkarmstr) for doing all the dirty work
12
13
**1.0.0-rc1** | Rewrote core of `JSONAPI` and `JSONAPIResource` and all unit tests to be up to spec with JSON API spec 1.0.0-rc3. Removed `JSONAPIResourceLinker`. Added `JSONAPIErrorResource`
13
14
**0.2.0** | Added `NSCopying` and `NSCoded` to `JSONAPIResource`; Added `JSONAPIResourceFormatter` to format values before getting mapped - [more info](#formatter)
14
15
**0.1.2** | `JSONAPIResource` IDs can either be numbers or strings (thanks [danylhebreux](https://github.com/danylhebreux)); `JSONAPIResource` subclass can have mappings defined to set JSON values into properties automatically - [more info](#resource-mappings)
15
16
**0.1.1** | Fixed linked resources with links so they actually link to other linked resources
16
17
**0.1.0** | Initial release
17
18
18
19
### Features
19
-
- Parses datasource into manageable objects of `JSONAPIResource`
20
-
- Allows resource types to be created into subclasses of `JSONAPIResource` using `JSONAPIResourceModeler`
21
-
- Set mapping for `JSONAPIResource` subclass to set JSON values into properties
20
+
- Allows resource types to be created into subclasses of `JSONAPIResource`
21
+
- Set mapping for `JSONAPIResource` subclass to set JSON values and relationships into properties
22
22
23
23
## Installation
24
24
@@ -30,198 +30,54 @@ Clone the repository and drop in the .h and .m files from the "Classes" director
30
30
JSONAPI is available through [CocoaPods](http://cocoapods.org), to install
31
31
it simply add the following line to your Podfile:
32
32
33
-
pod 'JSONAPI', '~> 1.0.0-rc1'
33
+
pod 'JSONAPI', '~> 1.0.0'
34
34
35
35
## Usage
36
36
37
37
### JSONAPI
38
38
`JSONAPI` parses and validates a JSON API document into a usable object. This object holds the response as an NSDictionary but provides methods to accomdate the JSON API format such as `meta`, `linked`, and `(NSArray*)resourcesForKey:(NSString*)key`.
39
39
40
40
### JSONAPIResource
41
-
`JSONAPIResource` is an object that holds data for each resource in a JSON API document. This objects holds the "id", "href", and "links" as properties but also the rest of the object as an NSDictionary that can be accessed through `(id)objectForKey:(NSString*)key`. There is also a method for retrieving linked resources from the JSON API document by using `(id)linkedResourceForKey:(NSString*)key`.
41
+
`JSONAPIResource` is an object that holds data for each resource in a JSON API document. This objects holds the "id", "href", and "links" as properties.
42
42
43
43
#### Resource mappings
44
-
`(NSDictionary*)mapKeysToProperties` can be overwritten to define a dictionary mapping of JSON keys to map into properties of a subclassed JSONAPIResource. Use a "links." prefix on the JSON key to map a linked JSONAPIResource model or array of JSONAPIResource models
45
-
46
-
#### Formatter
47
-
`JSONAPIResourceFormatter` is used to format values before getting mapped from `mapKeysToProperties`.
48
-
49
-
Below is an example to register a "Date" function to format a date in a NSString object to an NSDate object before its mapped to the JSONAPIResource instance.
if (![dateFormatter getObjectValue:&date forString:jsonValue range:nil error:&error]) {
61
-
NSLog(@"Date '%@' could not be parsed: %@", jsonValue, error);
62
-
}
63
-
64
-
return date;
65
-
}];
66
-
67
-
````
44
+
`+ (JSONAPIResourceDescriptor*)descriptor` should be overwritten to define descriptors for mapping of JSON keys and relationships into properties of a subclassed JSONAPIResource.
0 commit comments