Transforming a list into a list of objects

Options

Hi Xano community,

Im trying to trasnform 2 lists into a list of objects where each item in the list becomes a new object

I added the above and get the results as

So instead of teh above I want to get

{

Placement: 1

Budget: 10000

Placement: 2

Budget: 10000

Placement: 3

Budget: 10000

}

Any guidace is much appreacite it !

Tagged:

Best Answer

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Answer ✓
    Options

    TO do this, first make an empty array - call it “output” for the sake of this example. Make a for (not for-each) loop to iterate over the count of records in one of the two arrays. I'm assuming both arrays have the same count so it doesn't matter which one. THen you can get the record at the index provided as an iterator. Create a new object that will set each value (e.g placement_list:get:index goes into the path “Placement” in the new object). Then append the object to your array.

    At the end of the loop, object contains the array of objects you are looking for!

    We discuss this kind of harder data manipulation problem as part of our focus on the hardest 5% every day in our daily office hours on State Change.

Answers