Transforming a list into a list of objects
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 !
Best Answer
-
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
-
Thank @Ray Deck I just joined State Change hopefully we cna through in more detail
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback