Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Untransposing Object With Hyphen as Property Doesn't Work Correctly#1

Merged
henrytseng merged 3 commits intohenrytseng:masterhenrytseng/dataobject-parser:masterfrom
DavidTPate:masterCopy head branch name to clipboard
Jun 24, 2014
Merged

Untransposing Object With Hyphen as Property Doesn't Work Correctly#1
henrytseng merged 3 commits intohenrytseng:masterhenrytseng/dataobject-parser:masterfrom
DavidTPate:masterCopy head branch name to clipboard

Conversation

@DavidTPate
Copy link
Contributor

When using the library to untranspose an object which has a hyphen (or similar character) in the property name it is not correctly untransposed into a structured object.

For example, given an object like:

location: {
  'address-two': 'Grandma Road'
}

It is properly transposed to:

{
  'location.address-two': 'Grandma Road'
}

But, when attempting to untranspose it the following is the result:

location: {
  address: {
    two : 'Grandma Road'
  }
}

I took a look at how this is being handled and it looks like this result is being caused by the Regular Expression that is used to untranspose. My initial suggestion would be to handle this by having the following when transposing, for the example above:

{
  'location["address-two"]: 'Grandma Road'
}

But from looking through the rest of the library this looks like it would cause a conflict since instead of being treated as a property it would be treated as an array. Based on that requiring a lot of refactoring I just modified the regular expression to target hyphens so that they are properly parsed as part of the property name, not a child object.

henrytseng pushed a commit that referenced this pull request Jun 24, 2014
Untransposing Object With Hyphen as Property Doesn't Work Correctly
@henrytseng henrytseng merged commit cba26f5 into henrytseng:master Jun 24, 2014
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.