Hey there! In this blog post, we'll dive into the exciting new "Create Object from Entries" filter in Xano. This handy feature allows you to take a set of data, filter through it, and return a new object with only the desired data. It's perfect for situations where you need to remove blank values or unwanted data from an object, like when working with third-party API responses.
Let's start with an example JSON object that we'll be working with:
As you can see, this object has several key-value pairs, but two of them ("C" and "E") are empty.
The first step is to separate the keys and values of the object into separate arrays. We'll use the `entries` filter for this:
This filter gets the property entries of an object or array as a numerically indexed array of key-value pairs. After applying this filter, our data will look like this:
Next, we'll use the `filter_empty` filter to remove the key-value pairs with empty values:
Here, we specify the `value` path to indicate that we want to filter out empty values from the value part of the key-value pairs.
After applying this filter, our data will look like this:
Finally, we'll use the brand new "Create Object from Entries" filter to consolidate the filtered key-value pairs back into a single object:
This filter creates an object based on an array of key-value pairs, giving us our final result:
And just like that, we've effortlessly filtered out the empty values from our original object!
The "Create Object from Entries" filter in Xano provides a seamless way to clean up your data and remove unwanted values from objects. Whether you're working with third-party API responses or any other data source, this filter can save you time and hassle by automating the process of data cleaning.
Give it a try and let us know how it works for you! And don't forget to join the Xano community for more tips, tricks, and discussions around no-code development.
This transcript was AI generated to allow users to quickly answer technical questions about Xano.
I found it helpful
I need more support