Is there a way to access Java maps and lists as JavaScript objects in Rhino?
I have a map that contains only other maps and lists of primitives and strings, I would like to pass this Rhino script and make stuff for it and return the modified object back to Java, but since it is java.util.Map and java.util.List Objects, I canβt use the standard JavaScript associative array syntax. ie: fooMap.get("keyName") will work, but fooMap.keyName and fooMap["keyName"] will not.
I donβt know if there is an Rhino-specific way to do this, or if there is some kind of conversion / casting utility that will help. Commons BeanUtils is not enough, because to convert a map to a bean (which can be accessed through the associative array syntax), you must first create a class that has all the mutators / accessors named. I will not know the structure of the object at runtime.
Gary source share