Saving JSON key names to database

Hi there, must be my first post on the forum. So far I have come along quite nicely with bubble since October '23 but now I am stuck and need help.

I am trying to save JSON data to my database which I achieved successfully within another workflow for a different JSON but not this one. I am using a plugin called “Read JSON and get value by key” which works fantastic.

My JSON looks like this:

{
  "adhook": {
    "adhook_name": "Capture the Moment",
    "adhook_description": "Engage your audience with a story that resonates. 'Capture the Moment' leverages the power of emotional storytelling to connect with viewers, highlighting the transformative experience your product or service offers. Ideal for brands looking to create a lasting impression and build a strong emotional connection with their audience."
  }
}

My data type like this:

Now using the plugin mentioned above, I try to extract the values of name and description.

I then create a new thing saving the results as a string (array) to my data type.

I must be missing something as my data fields of name and description are empty. This exact setup works fine with a different JSON with nested arrays so I am utterly confused where I messed up with the “simpler” version.

Any feedback is much appreciated, thank you!

1 Like

Hey there,

There is probably a reason for it, but just wondering why you wouldn’t be using the normal backend workflow to receive this and store in the the DB?

Because I am still on the free plan exploring the possibilities of Bubble for my use case :slight_smile: And since it worked with another workflow, I didn’t see a need to upgrade yet.

1 Like

Noice, cool! Just wondering incase there was some other funky setup.

So name and desc are empty, does that raw json field populate?

Both those look like just strings in the example, rather than an array of strings like ‘[“one”, “two”, “three”]’ ? unless im missing something I would have expected your data type to just be text fields rather than lists of text?

1 Like

Thanks Oliver. I also tried strings when saving without success. Since there are up to 15 ad hooks you can generated, I want them all to be saved into one field (15 names and 15 descriptions) if that makes any sense. Hence my data fields are “List of texts”. I will try the string option when saving the thing again and report back :slight_smile:

It does make sense yep.

So potentially when creating a new object it could be adh_name “set list” result of read, each items adhook_name? so that then it would be grabbing an array for you?

Just to confirm does the raw-json field save into the DB?

Ah sorry missed to answer that part. Yes, the raw json is being saved.

1 Like

Cool, I think its an array - string miss match issue causing it.

Can you try feeding it an array and see if it works?

Need to see if I can figure this out. JSON is pretty new to me. But isn’t the ad hook itself an array containing multiple entries?

Yep, its an array of json objects, each with 2 fields which are both strings.

Your datatype would like a list of texts. So ideally you want to say “set list” and then feed it the list of the field you want, in this case “result of…'s each adhook’s adhook_name” for the first field, does that make sense? you’re then telling it to set the list to the list of all the adhook names you got back

So I created another name field type text (without the list of text option) and changed from string_array to string, just to see if anything gets saved. Nope. I have also change my initial JSON prompt to this:

{
  "adhooks": [
    {
      "adhook_name": "Capture the Moment",
      "adhook_description": "Engage your audience with a story that resonates."
    },
    {
      "adhook_name": "Capture the Moment",
      "adhook_description": "Engage your audience with a story that resonates."
    },
    {
      "adhook_name": "Capture the Moment",
      "adhook_description": "Engage your audience with a story that resonates."
    },
    {
      "adhook_name": "Capture the Moment",
      "adhook_description": "Engage your audience with a story that resonates."
    },
    {
      "adhook_name": "Capture the Moment",
      "adhook_description": "Engage your audience with a story that resonates."
    }
  ]
}

And then tested again with set list/ add as well as the string_array option again. I also tested how I get the key name using only adhook_name instead of adhooks.adhook_name etc. etc.

Every possible combination of possibilities have been tested without success. So I am utterly confused why this isn’t working at all. I think something is wrong with my Read JSON key name as I think that there isn’t any value being read so my database would always be empty and I search at the wrong place. But as noted, I tried different key namings without success.

1 Like

The key name does say adhooks where as the json says adhook but I assumed that was their markup for an array?

What does their docco say in terms of key name formatting?

No documentation available at all. Got this tip from a course I bought last year. For my other one which is working fine, my JSON goes like that:

{
  "product": {
    "product_summary": "A concise description of the product, its purpose, target audience, and primary function.",
    "product_features": [
      "Feature 1: A key functionality or characteristic that distinguishes the product.",
      "Feature 2: Another unique functionality or design element.",
      "Feature 3: A technical aspect or capability that enhances its use.",
      "Feature 4: An innovative component or feature that improves user experience.",
      "Feature 5: A sustainability or efficiency feature that appeals to conscious consumers."
    ],
    "product_benefits": [
      "Benefit 1: A direct advantage for the user resulting from Feature 1.",
      "Benefit 2: How Feature 2 solves a problem or meets a need for the user.",
      "Benefit 3: The positive impact of Feature 3 on the user's daily life or tasks.",
      "Benefit 4: The value added by Feature 4 in terms of convenience, time-saving, or cost-efficiency.",
      "Benefit 5: The long-term benefit or positive effect of Feature 5 on the user or environment."
    ],
    "product_unique_solution":

And then I use the plugin action for each key name like this:
5

6

And finally saving them as:
7

My brain’s tired after messing around with for that long :smiley:

1 Like

Okay cool I think it should be adhook.adhook_name ?

1 Like

Like just remove the “s” ? Since that then matches the same syntax?

1 Like

@bubble125 ; There come time when we get stuck, but guess what when we take a step back and think on it, we always find way to go through it, :+1:

1 Like

I see, pretty sure this is just a left over of my previous tests. I definitely tried every combo. With the latest JSON structure I am using it should work anyways. Giving up for now but thank you very much for your valuable time, much appreciated!

1 Like