Latest 0.4.1
Homepage https://github.com/hyperoslo/NSDictionary-HYPNestedAttributes
License MIT
Platforms ios 7.0, requires ARC
Dependencies NSString-HYPRelationshipParser
Authors

CI Status
Version
License
Platform

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.

Latest podspec

{
    "name": "NSDictionary-HYPNestedAttributes",
    "summary": "NSDictionary category that converts the flat relationships in a dictionary to a nested attributes format",
    "version": "0.4.1",
    "homepage": "https://github.com/hyperoslo/NSDictionary-HYPNestedAttributes",
    "license": "MIT",
    "authors": {
        "Hyper Interaktiv AS": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hyperoslo/NSDictionary-HYPNestedAttributes.git",
        "tag": "0.4.1"
    },
    "social_media_url": "https://twitter.com/hyperoslo",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Source/**/*",
    "dependencies": {
        "NSString-HYPRelationshipParser": [
            "~> 0.4.1"
        ]
    }
}

Pin It on Pinterest

Share This