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

Access object properties using brackets #114

Open
guisehn opened this issue Oct 4, 2017 · 4 comments
Open

Access object properties using brackets #114

guisehn opened this issue Oct 4, 2017 · 4 comments
Milestone

Comments

@guisehn
Copy link

guisehn commented Oct 4, 2017

Is there a way to access object properties using brackets? Currently, it seems there's no way to access an object property that has spaces on its name. e.g.

let expr = Parser.parse('a["property with spaces"]');
console.log(expr.evaluate({ a: { 'property with spaces': 5 } }));

throws

Error: parse error [1:2]: Unknown character "["
@silentmatt
Copy link
Owner

Right now there's no way to do that. I'm planning on adding support for arrays in the near future, and that would add support for this for free, so it's most likely coming soon.

@NordlingDev
Copy link

@silentmatt - Glad you're on it! Just realized I couldn't access properties within an array :(

@silentmatt silentmatt added this to the 2.0 milestone Dec 12, 2017
@gustavjorlov
Copy link

I'm also hoping for this feature 👍

@rfrm
Copy link

rfrm commented Jun 3, 2019

This might expose some security issues detailed here

@silentmatt silentmatt modified the milestones: 2.0, 3.0 Sep 9, 2019
ariesjia added a commit to ariesjia/expr-eval that referenced this issue Jul 5, 2022
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

No branches or pull requests

5 participants