Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
srp_jsonx_go & go_back
This is the first time I've attempted to use these two commands and I don't know whether I'm misunderstanding something or I've just done it wrong, which I guess is the same thing. But it's not doing what I'm expecting at least.
I have a json array with six objects.
I loop through the array using go and back the way I think they're intended to be used, but I only retrieve the data of the odd numbered rows.
iteration 1 worked just fine and the data I wanted was retrieved.
Then I went go back and went through iteration 2 and everything returned null so I thought, Ok, I've got it wrong.
But then iteration 3 went through and all the correct data was returned.
Iteration 4 - nulls
Iteration 5 - data
Iteration 6 - nulls.
The code is so much nicer to read then the long way round but I'm missing something. Well, 3 things - rows 2,4 and 6.
In typing this, I tested the code without the inner line_items loop. Without that loop, I get all six rows so the inner goback must be screwing me over somehow. But only every second time.

I have a json array with six objects.
I loop through the array using go and back the way I think they're intended to be used, but I only retrieve the data of the odd numbered rows.
iteration 1 worked just fine and the data I wanted was retrieved.
Then I went go back and went through iteration 2 and everything returned null so I thought, Ok, I've got it wrong.
But then iteration 3 went through and all the correct data was returned.
Iteration 4 - nulls
Iteration 5 - data
Iteration 6 - nulls.
For itemCnt = 1 to numItems
SRP_JsonX_Go('[':itemCnt:']')
orderId = SRP_JsonX_Get('id')
orderDate = SRP_JsonX_Get('date_created')
custID = SRP_JsonX_Get('customer_id')
custName = SRP_JsonX_Get('billing.first_name'):" ":SRP_JsonX_Get('billing.last_name')
orderNo = SRP_JsonX_Get('number')
orderStatus = SRP_JsonX_Get('status')
custNote = SRP_JsonX_Get('customer_note')
total = SRP_JsonX_Get('total')
numLineItems = SRP_JsonX_Count('line_items') ; //
for liCount = 1 to numLineItems
SRP_JsonX_Go('line_items[':liCount:']')
itemWebId = SRP_JsonX_Get('product_id')
thisItem = SRP_JsonX_Get('sku')
itemQty = SRP_JsonX_Get('quantity')
itemPrice = SRP_JsonX_Get('price')
itemTotal = SRP_JsonX_Get('total')
SRP_JsonX_GoBack() ; // go back to the parent item (the line_items object)
next liCount
SRP_JsonX_GoBack() ; // go back to the parent item (the array object)
Next itemCnt
The code is so much nicer to read then the long way round but I'm missing something. Well, 3 things - rows 2,4 and 6.
In typing this, I tested the code without the inner line_items loop. Without that loop, I get all six rows so the inner goback must be screwing me over somehow. But only every second time.


Comments
I've fallen into this trap before. The problem is with your inner "Go" command:
SRP_JsonX_Go('line_items[':liCount:']')This works, but you are technically jumping forward two levels from the current element. The "GoBack" command doesn't revert to where you started, it "changes the current element to the parent of the current element." The solution is to add a second "GoBack".
But someone changed the source data on me and there was only 3 items to extract this time. I was debugging and thinking, well at least I didn't get any null rows. :)
Looks like it works, thanks.
Each of the inner loops only had one item so fingers crossed it still works if there are multiple iterations for that loop
My issue was essentially the same as Dons. I was forgetting that the array node is the parent of the array element.
So I read the docs and thought I was going back to the parent but thinking that the parent was the outer array element.
Same same I guess, in not recognising that I'd gone two nodes down.
I guess what I'm saying here is even if you had a GoUp to do what the GoBack currently does, I still would have found myself in the same hole.
GoBack - goes back up one node
Return - returns you to where you were before you said Go.
That way we get both worlds and don't break anything.