https://github.com/travisjeffery/nsdictionary-trvsunderscorecamelcaseadditions
Convert NSDictionary keys to/from under_score/camelCase. Useful when working with JSON APIs, etc.
https://github.com/travisjeffery/nsdictionary-trvsunderscorecamelcaseadditions
Last synced: 11 months ago
JSON representation
Convert NSDictionary keys to/from under_score/camelCase. Useful when working with JSON APIs, etc.
- Host: GitHub
- URL: https://github.com/travisjeffery/nsdictionary-trvsunderscorecamelcaseadditions
- Owner: travisjeffery
- License: mit
- Created: 2012-12-30T18:45:36.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-12-30T19:33:27.000Z (about 13 years ago)
- Last Synced: 2025-01-31T17:17:55.539Z (11 months ago)
- Language: Objective-C
- Size: 160 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Category on NSDictionary providing some methods for converting the dictionary's keys to/from under_score/camelCase.
``` objective-c
@interface NSDictionary (TRVSUnderscoreCamelCaseAdditions)
- (NSDictionary *)dictionaryWithCamelCaseKeys;
- (NSDictionary *)dictionaryWithUnderscoreKeys;
@end
```
``` objective-c
[@{ @"user_name": @"travisjeffery", @"user_id" : @"Numero Uno" } dictionaryWithCamelCaseKeys];
# =>
@{ @"userName" : @"travisjeffery", @"userId" : @"Numero Uno"};
[@{ @"userName" : @"travisjeffery", @"userId" : @"Numero Uno"} dictionaryWithUnderscoreKeys];
# =>
@{ @"user_name": @"travisjeffery", @"user_id" : @"Numero Uno" };
```
### Install
Available as the Cocoapod `NSDictionary+TRVSUnderscoreCamelCaseAdditions`, or just use the `NSDictionary+TRVSUnderscoreCamelCaseAdditions.{m,h}` files.
### Self-Promotion
If you're feeling especially charitable or interested in Objective-C, JavaScript, Ruby, and Math, follow [travisjeffery](http://travisjeffery.com) on [Twitter](http://twitter.com/travisjeffery) and [GitHub](http://github.com/travisjeffery).
### License (MIT)
Copyright © Travis Jeffery. See LICENSE for details.