Are you asking how I do it? Turn json into a thing?
Create your object
{
“name”:”Chad”,
“Colour”:”purple”
}
Go to api connector, I have an api group called json_api
In that I would create an api called person and then press the button to manually add response.
Paste in object.
Save to initialise
You don’t need a url or anything other than a name for your api
You can now use it a million different ways but what we are trying to do here is turn object that come in the form of text, perhaps you have some JavaScript and you want to return an multi level object that you can actually access as a thing or what I use it for a lot is creating temporary objects before saving them.
The simplest way to tell you how to turn the object into a thing is to
Create a JavaScript to bubble function element
Set the bubble_fn_xx field
Check the publish box
Set the value to your data type you initialised
Now add a run js action behind. Button and add some code similar to below
Bubble_fn_xx({
“_api_c2_name”:”Chad”,
“_api_c2_Colour”:”purple”
});
You must add the api c2 stuff, for some reason bubble saves the object field names like this behind the scenes. Having a toggle in the bubble fn element to automatically apply these would be great and really time saving. Do not put the api c2 stuff in the api connector or you will get fields that look like “_api_c2__api_c2_name”
Run the js then you should be able to access your object as “JavaScript to Bubbles values name/colour” you can even have the bubble fan trigger an action. In the workflow with the run js if you want to use the data usually a 200ms delay is enough. You can do the same with the server script action, however the spin up time can often be annoying.
Good use case:
I create a temp list to display data in a rg without touching the db so I can have a user add things (such as tasks) and then I might have a save button that saves them. This way I don’t have to delete and create things in the db for no reason, particularly annoying to clean up tasks if a use refreshes the page or something.
The might be a task name and due date, so I have a button that does a run js, the bubble fn then turns it into an object and I can display in the rg with the rg being the container, instantly fast.
Editing the tasks takes a little magic but basically you recreate the json (you might even have a custom event for this purpose) send it to bubble fn then when adding it to the RG you filter out the old one