AutoTools JSON get had different order results

Discussion in 'AutoApps' started by Khaled w, Feb 26, 2018.

  1. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    Hi,
    I am trying to get all the results under <metric> in the attached file wuhourly.txt, with this line
    metric()
    store it into an array,
    but I get the attached results in tmp.txt
    all results are included, but different order for each section
    for example in original file they are:
    -3,-14,21,-9,-9999,-9,0,0,1027,-3....
    but in the results they are
    -3,-14,-9,0,21,-9999,0,1027,-9,-3,....
    Why is that? and how to fix it?
     

    Attached Files:

  2. bdiddy

    bdiddy New Member

    Joined:
    Jun 19, 2016
    Messages:
    9
    Likes Received:
    1
    I'm not going to do much research but I can tell you this happens to me whenever I have too many array separators. Meaning sometimes I need to do an array squash or I put an array separator into the autotools plug in and another separator when I'm setting the variable… something like that.
    Like so
    Variable set %this to blah|blah|
    Autotools json values %this|
    Etc
     
  3. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    This really makes the plugin not usable and not trusted in parsing lots of data, guess I will have to go back to the old tasker variable split methode
     
    Last edited: Feb 26, 2018
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Hi there. Json (or XML) reading IS reliable, it's just that the order is not relevant for the data. Order is only relevant in arrays, if you're not getting data from an array then the order doesn't matter because you're just reading out properties where no order is implied.

    Thus the reading of the data is correct :)

    Hope this clarifies it.
     
  5. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    Yes, it does read all data, but for my use order is important, as there are 324 results, i need to use the results order 1, 10, 19, .... which indicate same thing, such as high temperature for example, and 2, 11, 20, .... indicates low, and they are all marked as <metric>
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    In that case you should not use easy mode and specify the full path to the temperature so you don't get confusing results :)
     
  7. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    yes I tried that, the thing is with this method I need to make one line for each reading, so in the end it will be only 2 lines shorter than normal split variable method, and executing the line with Autotools is a little bit slower, so the code in split variable will be faster.
    If i was able to do it with the array() with one line for all 324 results, it would be much faster in Autotools,
    Anyhow, if you solve this in future releases it would be nice
     
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    You can do it in just one action though :) Simply get all the variables you need at once with arrays with the full path to the values you want. Can you give that a try?
     
  9. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    oh, how I did not not think of that, thanks, this worked, you can mark this thread as Solved.
    Just a remark though, using Autotools the task was 190 steps, and took 3 seconds to finish, using split variables it was 448 steps but took only around 1.5 seconds .
     
  10. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    That's to be expected because calling a plugin is a lot slower than doing native actions. But how many AutoTools actions are you calling in those 190 steps?
    Glad it works! :)
     
  11. Khaled w

    Khaled w Member

    Joined:
    Jan 4, 2017
    Messages:
    42
    Likes Received:
    0
    18 actions, the rest are mostly variable send to KLWP
     
  12. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Can't you put some of those in the same action?
     

Share This Page