Data Management

Create object

Hey there! In this guide, we'll explore how to create objects from lists of keys and values using Xano's handy create object filter. This can be super useful when working with data from external sources or when you need to dynamically construct objects based on user input.

Step 1: Define Your Keys

First, let's define a list of keys that will become the properties of our object. In Xano, you can create lists (or arrays) directly in the value field:

["name", "city", "age"]

This will create a variable containing the keys we want our object to have.

Step 2: Define Your Values

Next, we'll create another list with the corresponding values for each key:

["George", "Miami", 25]

Make sure the order of the values matches the order of the keys you defined in the previous step.

Step 3: Use the Create Object Filter

Now it's time to combine our lists of keys and values into a single object using the create object filter:

  1. Create a new variable.
  2. In the value field, start by typing the name of the variable containing your keys list.
  3. Click the "Add Filter" button and search for "create object".
  4. Select the "create object" filter from the list.
  5. In the filter's input field, type the name of the variable containing your values list.
  6. Click "Update" to apply the filter.

Your value field should now look something like this:

keys_variable | create_object: values_variable

Step 4: View Your Object

Finally, you can return the variable containing your newly created object. When you run your code, you should see the object printed in the response, with the keys and values properly mapped.

For example, if you used the keys ["name", "city", "age"] and values ["George", "Miami", 25], the output would be:

{
 "name": "George",
 "city": "Miami",
 "age": 25
}

And that's it! You've successfully created an object from lists of keys and values using Xano's create object filter. This can be incredibly handy when working with data from APIs, databases, or user input, allowing you to dynamically construct objects without writing any code.

Give it a try and let us know if you have any questions or need further assistance!

Sign up for Xano

Join 100,000+ people already building with Xano.

Start today and scale to millions.

Start building for free