Skip to content
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

Conversation

devxoul
Copy link
Contributor

@devxoul 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

@devxoul devxoul force-pushed the map-nested-key-delimiter branch from e278f8e to c21bf08 Compare October 15, 2016 15:30
@tristanhimmelman tristanhimmelman merged commit 4553dff into tristanhimmelman:master Oct 22, 2016
@devxoul devxoul deleted the map-nested-key-delimiter branch October 22, 2016 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants