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

Support numeric JSON properties using non-standard dot-notation syntax #47

Merged
merged 2 commits into from
Dec 5, 2016

Conversation

alexkwolfe
Copy link
Contributor

@alexkwolfe alexkwolfe commented Dec 2, 2016

Numeric property names are supported in JSON, but a mapping property that ends in . followed by a digit is assumed to be an array. This PR adds a new syntax for forcing numeric properties. Setting the mapping property to foo.bar{999} and value to "abc" will cause the following JSON to be rendered:

{ 
  "foo": {
    "bar": {
      "999": "abc"
    }
  }
}

See: https://activeprospect.zendesk.com/agent/tickets/11380

Copy link
Contributor

@cgrayson cgrayson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise l.g{2}m

@@ -2,24 +2,36 @@ _ = require('lodash')
flat = require('flat')
unidecode = require('unidecode')

numericPropertyRegexp = /(.*)(\{\d+\})$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only match the numeric pattern at the end of the string, right? Should something like 'foo.bar.baz{1}.bip' be supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shit. Probably.

@alexkwolfe alexkwolfe merged commit 329aac6 into master Dec 5, 2016
@alexkwolfe alexkwolfe deleted the numeric-json-properties branch December 5, 2016 04:31
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