Hello everyone ![]()
Today I want to share with you my
SetValueForKeyPath with self-generating path.
As you can see from the image above, if a path is pointed to with a non-existent list index, it will generate an error.
However, I noticed that if a key is created in a dictionary, it does not.
So why not handle everything through dictionaries?
well actually…
Index
1. SetValueForKeyPath
2. dictify
3. listify
4. GetValueAtKeyPath (Bonus)
5. AIA
SetValueForKeyPath
This is the main procedure that handles traversing the dictionary along the input path and generating the missing keys.
dictify
This procedure converts all lists into dictionaries by adding a __isList key that keeps track of what should be a list.
I will call them
proxy-list
listify
It performs the reverse operation, transforming proxy-list into actual lists.
Q: what if an index is skipped?
Me: well skip as many as you want, uncle Gian has thought of everything…(I think)
Currently a “null” string is generated, but it could be anything.
GetValueAtKeyPath (Bonus)
Since the error also occurred for this block, I created a procedure that does not return errors.
AIA
I’ve prepared a project that lets you see real-time updates to a dictionary, thanks to the implementation of a JsonViewer that is covered in this guide:
The project is fairly self-explanatory, but of course if you have any doubts about how it works, don’t hesitate to ask.
SGSetValueForKeyPath.aia (21.0 KB)
Before anyone panics seeing too many blocks in the main project, I’m also including an “essential” project with only the procedures covered in the guide.
SGSVFKP_Essential.aia (12.2 KB)
I’d like to point out that I’ve thoroughly tested the procedures and haven’t encountered any errors, but as we all know, bugs can be very well hidden.
If you find any, please report them so they can be fixed.











