Java Script <> Ruby array transfer
-
Hi all,
I have heard it is possible to transfer JS arrays to Ruby and back.
Could someone show me how to do it, please?<script language = "JavaScript"> tellSketchup(list) function tellSketchup(value) {window.location='skp;ValueChanged@'+value;}
'list' is an array. It is being passed to tellSketchup function.
dlg.add_action_callback("ValueChanged") {|d,mats|;puts mats.class;dlg.close}
Code above returns string.
Tomasz
-
Everything needs to passed as a string. See the link.
-
Thanks Jim for such a fast response! I was sure I have seen a video from SU API conference by Google and they mentioned arrays as well.. but it seems I am wrong.
Tomasz
EDIT:
On the same page I have found following :@unknownuser said:
Looking ahead: Using JSON for more complex data....It's a way where you can pass nested objects and arrays in a single command.
-
Yes, JSON is how you do it.
-
I was just looking at ruby-json. I noticed there were 2 ways to use it: one c-language extension, and one called "pure". Unfortunately, the "pure" is not so pure. It requires platform specific libraries also.
Advertisement