We just published a plugin ‘Json Generator’ as the bubble community may find it useful (especially those working with api stuff).
You can provide the fields in a workflow step ‘Set to’ of a ‘Json’ element on the page. The plugin will automatically generate a JSON string that you can use in your app as the ‘Json element’s output’.
How to use:
Install the plugin
Place the Json element on the page (you can place as many as u need).
Run the workflow step ‘Set to’ and reference the element.
This will update the ‘output’ Json of that element for your use
Speaking for us, we have a number of places in app where we’re writing JSON to send to other services.
For example, @copilot’s sendgrid plugin custom args, events sent to tools like segment or astronomer need to be json, there are many more.
Prior to this plugin, we’ve had to manually type the JSON block carefully into one field like I’ve shown above. It’s a serious pain to write and maintain – it’s easy to drop a " or , and the code breaks; bad things ensue.
Here’s an example for how to use it: 1) create the JSON 2) now you can reference the JSON in other actions.
Sure. I’d like to create scatter plots in my app, based on user data. I think plot.ly will be my best option. I’ve sorted out authentication and I can embed plots in my app using data that I enter in plot.ly itself.
Now I’m trying to figure out how to PUT a JSON object—which in my case is a table of text strings and numbers.
The format of the JSON object for plot.ly will be data structured into columns. So, I will have columns of text strings and columns of numbers to send, and the way to do that is to use JSON arrays.
Is there a way to capture an array of data from referenced things in this plugin in? I am looking for an output like this…
{
“Thing A Field 1” : “Thing A Field 1 Value”,
“Thing A Field 2” : “Thing A Field 2 Value”,
“Thing A Field 3 (List of Thing Bs)”:[{“Thing B1 Field 1”:“Thing B1 Field 1 Value”, “Thing B1 Field 2”:“Thing B1 Field 2 Value”,“Thing B1 Field 3 (List of Thing Cs)”:[{…}]}, {“Thing B2 Field 1”:“Thing B2 Field 1 Value”, “Thing B2 Field 2”:“Thing B2 Field 2 Value”,“Thing B2 Field 3 (List of Thing Cs)”:[{…}]}]
}
The generator allows you to provide other Json ojects as input so you can generate nested Jsons. Regarding arrays, either:
1: Env variable plugin: you can write simple code to construct ur json and output it to an env variable.
2. There’s something I’m planning to publish soon which should likely make this extremely easy. So you could wait for it (maybe a week or so)
thank you @gaurav I will loo at this. This could work. And yes, i would be very interested in having a JSON plug in that could easily compile all data and referenced data of a thing and generate a JSON. I cannot imagine I am the first person trying to do this. Thanks!!