-
Notifications
You must be signed in to change notification settings - Fork 29
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
Nested dicts as input? #20
Comments
I solved it with the following. Wondering why you don't have a recursive form of ToValue and FromValue in starlight already? Would be happy to add in a pull request
|
thanks for the code! There is a bug in the 'out' array initialisation. Corrected:
|
and just to clarify for anyone using this routine: Note that internally go does not have the tuple type. If you are serialising to/from JSON then tuples are represented as json arrays and therefore we cannot differentiate between list and tuple types (json conversion in this respect is lossy). Conversions through this function will assume a list type. |
I am really enjoying using this. I've been trying to get parsing of nested maps to work, but somehow the inner dicts loose their "mapness" and as a result can't be index.
Think input like:
x = {args : {"a" : {
"b" : "c"
}
}}
as input to the env. x is a starlark.StringDict, and accessing x works fine inside of starlark.
args is a perfectly valid command.
args["a"] also works, but args["a"]["b"] throws a runtime exception of:
Error: unhandled index operation starlight_interface<map[string]interface {}>[string]
Curious if you ever solved this?
In general, I've been playing around with some additional wrappers on top of FromValue and ToValue in order to make them work recursively -- the use case is getting json in and out of starlark. My from value recursion works really well, but I'm struggling with ToValue and figured I'd try and start a conversation
The text was updated successfully, but these errors were encountered: