This is whatās outputted as text and stored in my database. Not an issue. Now I need to parse it and turn each ID into a unique thing in the database. Iāve already brain stormed that this is fact possible with regex - but, is it possible another way? Perhaps a plugin?
To summarize, I need to create an object out of each ID, with each object having the pertaining information relative to its ID. This can be accomplished with Regex, but is there an easier way?
It would be really quick to make a plugin to organize this in a manner then pass it back to bubble all ready to be added to the database. Can you show me the fields for the data type you are hoping to create and I can throw one together. I will make it open source so you can see the code.
Thanks so much for putting this plugin together. I was looking for something like this last week. I looked at the App Data and the element workflows in the Editor and didnāt see how you looped through the rows in the RG to save each entry into the database.
I see use of a custom state (still learning the Bubble use of that), but not how you saved each row. Would I have to use a backend workflow to process the state value? (Iām trying to do something similar for a set of bookmarks. I processed first in regex, which works, but want to try JSON ā but canāt figure out creating a separate entry for each item.)
The workflowā āJSON.parse variable has been retrieved runs for each variable in the JSON object. On the bubble side it appears it is set up to just create one item but that workflow is triggered within a loop so it will occur multiple times at 100 milliseconds apart. On each iteration the values of the states of the element are updated and then the variable retrieved event is triggered.
So the plugin is not looping through the repeating group but it is creating the data that is displayed in the repeating group. If you pass in a string of four variables then āJSON.parse variable has been receivedā will run four times and four items will display in the repeating group.
You can fork this code into your own plugin and make it more dynamic. For instance if you gave the plugin element like 10 text fields you could just type in whatever the objects keys were named and then reference those in the loop and it can pull data based on the structure of the JSON string you pass in.
I appreciate the response. I saw earlier how a single item is being created in the database, but not entirely sure how the loop is integrated. Itās most likely because Iām not yet familiar with how to set up loops in Bubble. (Although I do see the page view + 1 setup; will study further.) Once I find how to fork a Bubble plugin, Iāll try it out for my bookmarking case. Thanks once again for this plugin. (Iām originally a Web developer myself, but still learning how to think and do in Bubble.)
EDIT: The fork button for your plugin seems to be grayed out for me. Maybe I need to upgrade from a free account first.
So this isnāt customizable for our individual scenarios? I noticed that when I placed the element on the page it has all your custom states shown on your example page. I also donāt know how to make my own plugin.
If you go to the plugin page and click the āSee the Codeā button, you will be able to see the āstatesā and fields I used and this will give you an idea of what you need to change to match your needs. Once you feel like you know how to change it then click the āForkā button on the same page and you will have your own copy of the plugin that you can edit. Just make it āPrivateā on the Settings tab and add your app as an authorized app. I didnāt take too much time to explain in detail what everything is doing, but I feel like anyone without any coding experience could be able to look at the finished product and the code to determine what should be changed for their use case.
It seems this isnāt as easy of a process as it sounded. I now understand what variables/states that I need to change, but I donāt understand the forking process. Do I need to use GitHub? Also, the Fork button on the plugin page is disabled. Will you help me out here?
Iām not sure about the forking process to be honest. Maybe it would be easier to open the plugin code side by side next to a new plugin and just copy everything over as it isnāt much.
Hi @williamtisdale-- first, thanks so much for making JSON.parse() ! I read back through the messages here and saw that you really helped people out.
Iām embarrassed to ask what is probably a basic question, but Iām still feeling my way with Bubble. The question is: where in the Workflow do I specify the input string that the plug-in will parse? I have changed the exposed states and variables to suit my JSON and database structure, but the plug-in never actually gets called in my workflow.
For example, in your example app, the input string is placed in the text box Input A, but I donāt see where in the workflow that input is being passed to the JSON.parse() plug-in. I wondered if itās something to do with setting an empty state with value ānoā but I donāt understand what that should do.
Sorry if Iām missing something super basic, but I wonder if you can point me in the right direction. I hope Iāve explained it clearly.
The conditionals on the JSON.parse() element will use the value of Input A when a custom state is triggered and the state is triggered when the JSON button is clicked.
Looking at that now, I can see how that is confusing.
On lines 4 and 15 it should only be called JSON and not akJSON. JSON is a built in variable in Javascript/jQuery so it is not working when the name is changed.
Thatās it! Youāre super kind to reply so helpfully.
Plug-in is now working with your variables and data; I just canāt get it to work with mine. I think itās because my data is strings and arrays rather than numbers. Iāve changed the Exposed States to Text type rather than Number type, but I have a feeling I may need to change something about the instance.publishState or variable terminology so that it deals correctly with strings. If you have the patience to reply, please help me out of my misery. Iām of course also googling to learn how JSON deals with strings and arrays rather than integers etc, so maybe will figure it out eventually.
Thanks again for your super helpful replies above-- theyāve solved most of the problem already.
OK, Iāve found it: the way the plug-in is constructed, I need to enclose all keys in the JSON input in
{āvariablesā: [ ā¦ ]}
All good now. Thanks again @williamtisdale ā I owe you one!