How to Convert Flat JSON Fields to an Array of Objects?

Hello everyone,

I’m working with an API response that includes educational data in this case, but it’s currently structured with each piece of data as a separate string. Here’s a simplified version of the response I receive:

{
  "data": [
    {
      "data_educations_0_companyId": "123456",
      "data_educations_0_companyLink1": "https://www.linkedin.com/company/123456/",
      "data_educations_0_logo": "https://media.licdn.com/dms/image/random_string/company-logo_200_200/0/random_string/logo1",
      "data_educations_0_title": "Example University",
      "data_educations_0_subtitle": "Computer Science",
      "data_educations_0_caption": "Sep 2018 - Jun 2022",
      "data_educations_1_companyId": "789012",
      "data_educations_1_companyLink1": "https://www.linkedin.com/company/789012/",
      "data_educations_1_logo": "https://media.licdn.com/dms/image/random_string/company-logo_200_200/0/random_string/logo2",
      "data_educations_1_title": "Example College",
      "data_educations_1_subtitle": "Bachelor's degree, Software Engineering",
      "data_educations_1_caption": "Sep 2014 - Jun 2018"
    }
  ]
}

I want to restructure this data into an array of objects for easier manipulation and readability. The desired format is:

{
  "educations": [
    {
      "companyId": "123456",
      "companyLink": "https://www.linkedin.com/company/123456/",
      "logo": "https://media.licdn.com/dms/image/random_string/company-logo_200_200/0/random_string/logo1",
      "title": "Example University",
      "subtitle": "Computer Science",
      "caption": "Sep 2018 - Jun 2022"
    },
    {
      "companyId": "789012",
      "companyLink": "https://www.linkedin.com/company/789012/",
      "logo": "https://media.licdn.com/dms/image/random_string/company-logo_200_200/0/random_string/logo2",
      "title": "Example College",
      "subtitle": "Bachelor's degree, Software Engineering",
      "caption": "Sep 2014 - Jun 2018"
    }
  ]
}

Anyone an idea on how to achieve this? Preferably with vanilla Bubble. Thanks!

Turns out ChatGPT does an amazing job reformatting this json. However, if anyone knows a faster (and cheaper) method in Bubble, please do share! :slight_smile:

It’s not a solution using Bubble to reformat it but you could send the initial JSON to a Cloudflare/Google/Amazing function and have them return it in the format you want.

It would probably be free and a lot faster doing than using ChatGPT.

You could use ChatGPT to write the code to do it (or that could be your starting point). @jamesdevonport has an excellent video showing how to set up a Cloudflare Worker to do this sorta thing in 15 minutes: x.com

1 Like

Hi @oliviercoolen, how are you?

@NoCodeDataArtisan might be able to give some insight as he is the creator of the plugin JSON assistant.

We can also help with implementing it into your platform :wink:

1 Like

Hello @oliviercoolen,

I trust you’re doing well. I’d like to extend my gratitude to @pattokane for recommending our plugin.

As he pointed out, the plugin allows you to manipulate JSON however you see fit.

Indeed, I have constructed what you require, considering it’s a particularly complex use case. You can view the outcome on this page:

Preview:
My Page (bubbleapps.io)

Editor:
Artisan-plugnplay | Bubble Editor

You can extract each item and convert it to the Bubble data type, making it easier to use in other elements like Repeating Groups (RGs).

1 Like