New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to customize nested key delimiter #629

Merged
merged 5 commits into from Oct 22, 2016

Conversation

Projects
None yet
2 participants
@devxoul
Contributor

devxoul commented Oct 15, 2016

Summary

This PR makes it available to use custom nested key delimiter in mapping.

Background

Imagine that we have a JSON dictionary which has nested-dot-containing keys:

{
  "kr.xoul.user": {
    "kr.xoul.name": "Suyeol Jeon",
    "kr.xoul.username": "devxoul"
  }
}

In this case, mapping function would not work properly.

func mapping(map: Map) {
  // this will parse the key as ["kr"]["xoul"]["user"]["kr"]["xoul"]["name"]
  name <- map["kr.xoul.user.kr.xoul.name"]
}

Improvement

Adding delimiter parameter to map subscript.

func mapping(map: Map) {
  // this will parse the key as ["kr.xoul.user"]["kr.xoul.name"]
  name <- map["kr.xoul.user->kr.xoul.name", delimiter: "->"]
}

Notes

  • This PR also contains nested key support in ImmutableMappable. (will it better separating to another PR?)

Related Issues

@tristanhimmelman tristanhimmelman merged commit 4553dff into Hearst-DD:master Oct 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@devxoul devxoul deleted the devxoul:map-nested-key-delimiter branch Oct 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment