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

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

Any update on this issue? I've been aiming for a while to do it and not able to do it. The issue does seem to be that i is not being replaced in the WGET function

Found a fix for this issue after months of on off trying

You need to nest the i like so:

"wg(gv(Examp), json, .[" + " + i + " + "].example)"

Thanks. This solution rescued me from a large nested if statement!

[EDIT]Nevermind Ben krajancic's solution worked, you just have to be very careful with the quotes and "+"

Same problem here,

This kode works :


But if I replace 0 by i it breaks. I tried several alternatives with or without quotes but no luck for now...

No error with this kode:


but nothing is displayed.