Skip to content

Commit 12a67c4

Browse files
committed
Merge pull request jsonmodel#203 from jonathanng/patch-1
Update README.md
2 parents 3280c5a + f93a371 commit 12a67c4

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Examples
453453
454454
#### Using the built-in thin HTTP client
455455
456-
```ruby
456+
```objective-c
457457
458458
//add extra headers
459459
[[JSONHTTPClient requestHeaders] setValue:@"MySecret" forKey:@"AuthorizationToken"];
@@ -470,7 +470,7 @@ Examples
470470

471471
#### Export model to NSDictionary or to JSON text
472472

473-
```ruby
473+
```objective-c
474474

475475
ProductModel* pm = [[ProductModel alloc] initWithString:jsonString error:nil];
476476
pm.name = @"Changed Name";
@@ -483,8 +483,29 @@ NSString* string = [pm toJSONString];
483483

484484
```
485485
486+
#### Custom data transformers
487+
488+
```objective-c
489+
490+
@implementation JSONValueTransformer (CustomTransformer)
491+
492+
- (NSDate *)NSDateFromNSString:(NSString*)string {
493+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
494+
[formatter setDateFormat:APIDateFormat];
495+
return [formatter dateFromString:string];
496+
}
497+
498+
- (NSString *)JSONObjectFromNSDate:(NSDate *)date {
499+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
500+
[formatter setDateFormat:APIDateFormat];
501+
return [formatter stringFromDate:date];
502+
}
503+
504+
@end
505+
506+
```
507+
486508
* json validation
487-
* data transformations
488509
* error handling
489510
* custom data validation
490511
* automatic compare and equality features

0 commit comments

Comments
 (0)