-
Notifications
You must be signed in to change notification settings - Fork 55
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 for dot notation variables and nested context_map #117
Comments
No, that is not possible. I was thinking about implementing something like this at some point, but I think I would rather leave that up to a pull request. |
I think we can expand this feature to a native JSON support, I will try to make a PR later, this will a big and useful feature. proposal eval("
enemy = { x: 100, y: 200, z: get_z() };
// return the coordinate
(enemy.x, enemy.y, enemy.z)
") |
This is how I am doing this currently: fn add_value_to_context(
&self,
prefix: &str,
value: &serde_json::Value,
context: &mut HashMapContext,
) -> Result<(), EvalexprError> {
match value {
serde_json::Value::Object(obj) => {
for (key, value) in obj {
let new_key = if prefix.is_empty() {
key.to_string()
} else {
format!("{}.{}", prefix, key)
};
self.add_value_to_context(&new_key, value, context)?;
}
}
... And I can access a variable as such:
|
@odyslam do you have a pr for this implementation or can you point to where this code is implemented |
Hi @odyslam did you make any further progress on this? |
Is it possible to access variables in context by dot notation like this?
The text was updated successfully, but these errors were encountered: