Creating a dictionary in the function stack

Options
Georges Duverger
Georges Duverger Trusted Xano Expert
👋 Hello. First post here. I'm not totally sure if this belongs to the Transforming Data space or not so I'm posting it here just in case.

How would I go about creating a `{"foo": "bar"}` object in a function stack? I tried a few different things but I haven't been successful yet.

My long term plan is to have an endpoint return something like the following dictionary with static data (`foo` and `bar`) to test out things on the frontend.
{
"foo1": "bar1",
"foo2": ["bar21", "bar22", "bar23"],
"foo3": {
"foo31": "bar31",
"foo32": "bar32",
"foo33": "bar33"
},
"foo4": [
{"foo41": "bar41"},
{"foo42": "bar42"},
{"foo43": "bar43"}
],
"foo5": "bar5"
}Thank you. 🙏

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    You can create a variable and use import JSON to create it. You should be able to paste this above into a variable. But let me know if you have any issues
  • Georges Duverger
    Georges Duverger Trusted Xano Expert
    Options
     It worked. Not only it imported the JSON but, because of how the UI is set up, it taught me how to do it manually if I ever wanted to. I love it! Thanks for the late-night support, Michael.
  • gbdoin
    gbdoin Member
    edited December 2022
    Options

    @Michael Udinski quick follow-up question for this one: is it possible to use actual variable names, like let's say user.name instead of "bar1". And then use json IMPORT, expecting it to directly map the variables to the actual objects?