JSON formatting for strings

I’m pulling data from one API, doing some manipulations and pushing into another API.

For example, extracting Initiatives from Perdoo into Tasks in ASANA.

This mostly works just fine except every now and then I get JSON formatting errors as the data pulled from one API includes characters that need to be escaped in the JSON post to the other API.

For example, I have a BODY payload for the ASANA task creation like so:

{
  "data": {
    "completed": false,
    "custom_fields": {
      "1174838407251453": "{progress}",
      "1174838407251441": "{perdooid}"
    },
    "due_on": "{due_on}",
    "name": "{name}",
    "notes": "Perdoo initiative created.",
    "projects": [
      "1174838407251433"
    ],
    "resource_subtype": "default_task",
    "start_on": "{start_on}"
  }
}

The {name} field is the issue as it occasionally has characters that break JSON without escaping.

I need an option to either:

  • JSON format strings in a column, or;
  • JSON format the {columnname} by default or as an advanced option

Is either option possible now?

I found Magic Clean Data but it doesn’t appear to escape "". The only way i can get the API2API process to work is make sure "" are not in the title of the Initiative.

These are pretty common characters for users. I assume i could start running a bunch of REGEX formatters on the column… but this seems like a pretty lousy way to do a standard JSON format.

1 Like

Hey Geoff! If you need to escape the quotes too, you can use a Find/Replace step, and find the " character and replace it with \" to escape it in JSON!

1 Like

Thanks for that – its great that i can put through a whole range of validation options via Find/Replace and/or REGEX.

However, it would make sense to have a general JSON value format available given the propensity for REST APIs to use JSON. Perhaps Magic Clean Data could be made more magical.

1 Like