Minced 0.4.0

Minced 0.4.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2015

Maintained by Elvis Nuñez, Hyper Interaktiv AS, Jacob Andersson.



Minced 0.4.0

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

Usage

// 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

[
  {
    "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

NSArray *mincedJSON = [JSON minced_JSONObjectsKeysWithNonnulls];

// Realm
RLMRealm *realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
[self createOrUpdateInDefaultRealmWithObject:mincedJSON];
[realm commitWriteTransaction];

Minced 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. To install it, simply add the following line to your Podfile:

pod 'Minced'

Author

Hyper Interaktiv AS, [email protected]

License

Minced is available under the MIT license. See the LICENSE file for more info.