NSDictionary-HYPNestedAttributes 0.4.1

NSDictionary-HYPNestedAttributes 0.4.1

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

Maintained by Elvis Nuñez.



This is a category on NSDictionary that converts the flat relationships in a dictionary to a nested attributes format.

JSON Nested Attributes

NSDictionary *dictionary = @{@"first_name" : @"Chris",
                             @"contacts[0].name" : @"Tim",
                             @"contacts[0].phone_number" : @"444444",
                             @"contacts[1].name" : @"Johannes",
                             @"contacts[1].phone_number" : @"555555"};


NSDictionary *nestedAttributesDictionary = [dictionary hyp_JSONNestedAttributes];
"first_name": "Chris",
"contacts": [
  {
    "name": "Tim",
    "phone_number": "444444"
  },
  {
    "name": "Johannes",
    "phone_number": "555555"
  }
]

Rails Nested Attributes

NSDictionary *dictionary = @{@"first_name" : @"Chris",
                             @"contacts[0].name" : @"Tim",
                             @"contacts[0].phone_number" : @"444444",
                             @"contacts[1].name" : @"Johannes",
                             @"contacts[1].phone_number" : @"555555"};


NSDictionary *nestedAttributesDictionary = [dictionary hyp_railsNestedAttributes];
"first_name": "Chris",
"contacts_attributes": {
    "0": {
      "name": "Tim",
      "phone_number": "444444"
    },
    "1": {
      "name": "Johannes",
      "phone_number": "555555"
    }
 }

Installation

NSDictionary-HYPNestedAttributes is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NSDictionary-HYPNestedAttributes'

Author

Hyper Interaktiv AS, [email protected]

License

NSDictionary-HYPNestedAttributes is available under the MIT license. See the LICENSE file for more info.