gval
gval copied to clipboard
Unable to define and look up array
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.
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.
Makes sense. I would appreciate a fix for this. 🙂
I can do this but it will take some time.