RejectedSoftware Forums

Sign up

reversing the order of a JSON array element

I have the code:

foreach(THREAD; PAGE["threadList"])
{
     ~Some code
}

My question: How can I reverse the order of PAGE["threadList"] during iteration so it is returned as 98765 instead of 56789? The method used for general arrays (.reverse or foreach_reverse) does not work.

Re: reversing the order of a JSON array element

Am 17.09.2016 um 03:09 schrieb Chuck:

I have the code:

foreach(THREAD; PAGE["threadList"])
{
     ~Some code
}

My question: How can I reverse the order of PAGE["threadList"] during iteration so it is returned as 98765 instead of 56789? The method used for general arrays (.reverse or foreach_reverse) does not work.

Getting an array of Json values explicitly should do the trick:

foreach_reverse (THREAD; PAGE["threadList"].get!(Json[]))