For loop does not play well with wget

An extensive report of the problem can be found here, but the general idea is that fl (for loop) does not play nicely with wg (wget). I tried to iterate through an array inside of a json file, but there were two problems:

  1. wget cannot parse variable "i" inside of square brackets ("[ ]")
  2. if we make the array call static (jsonArray[0]) within the for loop and iterate n amount of times (1 through n), it will display jsonArray[0] more than n times

1 reply


Did you try this:

$fl(1, 5, "i + 1", "if(wg(gv(URL), json, .stats.activePlayers[" + i + "].personId) = gv(Pts1), it works!, not working)")$

The "i" var statement must be OUT of the quotes, everything else inside the quotes

I tried two things, 

1. $fl(1, 5, "i + 1", "(wg(gv(URL), json, .stats.activePlayers[" + 0 + "].personId)")$

This returned the correct result, printing the value at .stats.activePlayers[0].personId 5 times

2. $fl(1, 5, "i + 1", "(wg(gv(URL), json, .stats.activePlayers[" + i + "].personId)")$

Now, when I replaced index 0 with variable i, the kode outputs an empty string and gives no error message

This should work, will try to reproduce