https://github.com/hyperoslo/minced
Convert JSON keys to camelCase
https://github.com/hyperoslo/minced
Last synced: about 1 year ago
JSON representation
Convert JSON keys to camelCase
- Host: GitHub
- URL: https://github.com/hyperoslo/minced
- Owner: hyperoslo
- License: other
- Created: 2015-03-11T16:58:49.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-18T14:10:40.000Z (about 11 years ago)
- Last Synced: 2024-10-12T23:34:36.980Z (over 1 year ago)
- Language: Objective-C
- Homepage: http://hyper.no
- Size: 406 KB
- Stars: 14
- Watchers: 16
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Minced
[](https://travis-ci.org/hyperoslo/Minced)
[](http://cocoadocs.org/docsets/Minced)
[](http://cocoadocs.org/docsets/Minced)
[](http://cocoadocs.org/docsets/Minced)
> Mincing is a food preparation technique in which food ingredients are finely divided into uniform pieces.
Minced converts JSON keys to camelCase an adds support for replacement of JSON null values with empty strings.
This is especially useful as a workaround for avoiding crashes due to null values when using Realm. More info: [Issue #628](https://github.com/realm/realm-cocoa/issues/628)
## Usage
```objc
// Converts all the keys in the JSON to camelCase
- (id)minced_JSONKeys;
- (NSArray *)minced_JSONObjectsKeys;
- (NSDictionary *)minced_JSONObjectKeys;
// Converts all the keys in the JSON to camelCase and replaces null values with an empty string
- (id)minced_JSONKeysWithNonnulls;
- (NSArray *)minced_JSONObjectsKeysWithNonnulls;
- (NSDictionary *)minced_JSONObjectKeysWithNonnulls;
```
## Example
#### JSON
```json
[
{
"created_at":null,
"updated_at":"2015-03-11",
"window":{
"title":null,
"name":"hyper_window"
}
},
{
"created_at":null,
"updated_at":"2015-03-12",
"panel":{
"title":null,
"name":"hyper_panel"
}
}
]
```
#### Code
```objc
NSArray *mincedJSON = [JSON minced_JSONObjectsKeysWithNonnulls];
// Realm
RLMRealm *realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
[self createOrUpdateInDefaultRealmWithObject:mincedJSON];
[realm commitWriteTransaction];
```
#### Minced JSON
```json
[
{
"createdAt":"",
"updatedAt":"2015-03-11",
"window":{
"title":"",
"name":"hyper_window"
}
},
{
"createdAt":"",
"updatedAt":"2015-03-12",
"panel":{
"title":"",
"name":"hyper_panel"
}
}
]
```
## Installation
**Minced** is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
`pod 'Minced'`
## Author
Hyper Interaktiv AS, teknologi@hyper.no
## License
**Minced** is available under the MIT license. See the LICENSE file for more info.