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

Unable to define and look up array #42

Open
preciselytom opened this issue Sep 23, 2020 · 3 comments
Open

Unable to define and look up array #42

preciselytom opened this issue Sep 23, 2020 · 3 comments

Comments

@preciselytom
Copy link

According to the readme, you can define an array in gval:

Json Arrays : [1, 2, "foo"]

And you can look up an element from an array:

Map and array elements and Struct Field can be accessed via [].
foo[0]

Then I should be able to define an array and look up an element:

[10,11,12,13][2]

I expected this to return 12, but instead I got:

&errors.errorString{s:"parsing error: [10,11,12,13][2]\t:1:14 - 1:15 unexpected \"[\" while scanning operator"}

What I'm trying to do is let a customer define an array in a gval string, and input from their user will be used to look up an element:

["foo", "bar", ...][x]

Where "foo", "bar", ... is written by an admin, and x comes from an end user.

@generikvault
Copy link
Collaborator

Yes the VariableSelector is currently fixed tied to variables. That is the reason why [10,11,12,13][2] can't be parsed.

The VariableSelector could instead be implemented as a PostfixOperator.

@preciselytom
Copy link
Author

Makes sense. I would appreciate a fix for this. 🙂

@generikvault
Copy link
Collaborator

I can do this but it will take some time.

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

2 participants