• Isadora
  • Get it
  • Forum
  • Help
  • ADD-ONS
  • Newsletter
  • Impressum
  • Dsgvo
  • Impressum
Forum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    Issues with loading external data using JSON with Javascript actor

    How To... ?
    2
    4
    1069
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lucyhg last edited by

      I found this article by Ryan Webber helpful: http://troikatronix.com/support/kb/how-to-load-external-data-with-javascript/

      I followed the above mentioned instructions to load a string of javascript objects from an external file using JSON. All works well - the javascript actor references the external file and pulls up the appropriate value, but the parsing does not work within the Isadora scene, only when I change the actual Javascript.
      For example, using the code offered in the link above, when I use
      return [data.employees[2].firstname];
      and change the number [2] within the code, that changes the output.
      When I change the number for input 1 in the Isadora actor, my thinking was that the output would go through the data sequence. It remains stuck on whatever number is designated within the JSON code.
      My question is: how should I edit the code below so that I can pulse through the string in my JSON.txt file? As of now, only by changing that number 2 below can I change the data called up for output1.

      include('JSON.txt');
      data = JSON.parse(data);

      function main()
      {
      return [data.employees[2].firstName];
      }

      Appreciatively...

      1 Reply Last reply Reply Quote 0
      • DusX
        DusX Tech Staff last edited by

        First, I will let you know I have done an updated version of this tutorial as part of the official Isadora KB.
        It can be found here: http://troikatronix.com/support/kb/how-to-load-external-data-with-javascript/

        It covers in more detail the relation between the different elements.
        What you want to do is use one of your inputs (available via the args list in Javascript) as the variable that is selecting the element of the Json list.
        This is covered in this new version of the tutorial.
        but quickly "return [data.employees[arguments[0]].firstName];"
        will allow you to use Input 1 to select the different firstnames from the JSON data.

        Troikatronix Technical Support

        • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
        • Isadora Add-ons: https://troikatronix.com/add-ons/
        • My Add-ons: https://troikatronix.com/add-ons/?u=dusx

        Running: Win 10 64bit, i7-8750H, M.2 PCIe SSD's, 16gb DDR4-2666, nVidia GTX 1070 | located in Ontario Canada.

        1 Reply Last reply Reply Quote 0
        • L
          lucyhg last edited by

          That makes sense. Thank you, Ryan. I will try it out.

          1 Reply Last reply Reply Quote 0
          • L
            lucyhg last edited by

            That's working. Thank you!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post