How to modify APIs JSON response

Hi all - I’ working with the Google Search Console API and the way it formats the JSON return is causing me various headaches.

What it returns basically looks like this:

{
  "rows": [
    {
      "keys": [
        "search term 1",
        "https://example.com/article-about-keyword-1/"
      ],
      "clicks": 24,
      "impressions": 54,
      "ctr": 0.4444444444444444,
      "position": 2.037037037037037
    },
    {
      "keys": [
        "search term 2",
        "https://example.com/article-about-keyword-2/"
      ],
      "clicks": 17,
      "impressions": 107,
      "ctr": 0.1588785046728972,
      "position": 2.663551401869159
    }
],
  "responseAggregationType": "byPage"
}

And it’s this part that is causing me the issues:

 "keys": [
            "search term 1",
            "https://example.com/article-about-keyword-1/"
          ],

What I’d ideally want is a structure more like this:

{
  "rows": [
    {
      "keyword": search term 1,
      "URL": https://example.com/article-about-keyword-1/,
      "clicks": 24,
      "impressions": 54,
      "ctr": 0.4444444444444444,
      "position": 2.037037037037037
    },
    {
      "keyword": search term 2,
      "URL": https://example.com/article-about-keyword-2/,
      "clicks": 17,
      "impressions": 107,
      "ctr": 0.1588785046728972,
      "position": 2.663551401869159
    }
],
  "responseAggregationType": "byPage"
}

Where the ‘Keys’ are labeled as ‘Keyword’ and ‘URL’ rather than just an unlabelled list.

I’ve thought of a few things like using JSONata to modify it, but not sure if you can do that in Bubble. Thought about using @keith List Shifter Process list function to somehow modify the results into a processed list. But maybe there is something simple I’m missing.

Any thoughts/help appreciated. (oh and yes you can spell it labelled or labeled apparently :slight_smile: )

just update the structure using format as text bubble function

1 Like

@loulouaying1204 Sorry, can you explain that a bit more.

A nice little script could probably handle this for you and return as desired!


something like this