JSON Stringify for some fields

Hello,

I have a multidimensional JSON that I map with a google sheets.

  • For the 1st level, I map it normally
  • For the 2nd level, I’d like to take the JSON as a string and put it in the Sheets field as is

For example

  • name → name field
  • website → website field
  • about → about field (with subtree as json string inside)
  • | - random data 1
  • | - random data 2

I’d like to put the JSON of what is in “about” as a json string in my field.

I’ve tried “toString(about)” but that gives me an “(object)” value in my Gsheets field.
I’ve tried “flatten” also but not compatible with a JSON object

How could I “stringify” the subtree as a string value? I thought that was “toString” purpose to take any kind of data…

Thanks for your help!

Hi @Romain_BOYER,

Would it be possible to post an example of the data you are starting with and what you want the end result to look like?

There are a few JSON modules available that you might be able to use.

You may need to use Transform to JSON module. The results of that would then go into your Google Sheet.

2 Likes

Faced the same problem… I need to stringify a JSON, because otherwise I get “Bad Request” response. The problem that I am providing a JSON in one of JSON’s parameter values.

Non-working JSON format

{
  "preferences": [
    {
      "key": "gender",
      "external_id": "30130450399498",
      "answers": ["Man"]
    },

Stringified JSON that works


{\"preferences\": [{\"key\": \"gender\", \"external_id\": \"30130450399498\", \"answers\": [\"Man\"]}

There is only a piece of big file, so it might be a JSON closing issues - ignore it :slight_smile:

Maybe you are aware of the solution to this issue?

Welcome to the Make community!

That looks like a new question, could you please create a separate topic for this?

While it’s tempting to continue an existing thread, a more effective approach would be to start a new topic. It helps other community users to respond to your query, and keeps our space organised for everyone. If you start a new conversation you are also more likely to get help from other users. You can refer others back to a related topic by including that link in your question. Thank you for understanding and keeping our community neat and tidy.

The “New Topic” link can be found in the top-right of the header:
Screenshot_2023-12-19_091207

4 Likes