What Is the Best Way to Resolve a JSON Parsing Error?

This topic was automatically generated from Slack. You can find the original thread here.

This is the error we’re encountering, we believe its because JSON stuff is trying to parse something thats already parsed, which is causing the code to crash. Is there any specific way we should go about this?

Hi Ethan, if you’ve already parsed the JSON into an object, but the action accepts a string and parses the JSON for you, try passing:

{{ JSON.stringify(your_object_here) }}

for example:

{{ JSON.stringify(steps.trigger.event) }}

if that doesn’t work, can you take a screenshot of the full configuration for that action? I’d like to see exactly what action it is, and what you’re passing. All of our actions are on GitHub, so we can take a look at the code together to see if we can figure out what’s wrong.

These are the two steps

Yes, that action does indeed try to parse the data passed in the Data field: pipedream/create-record.mjs at af54fb997a05dcd0a39b527f5f8bb87d224b32aa · PipedreamHQ/pipedream · GitHub

Can you try passing:

{{ JSON.stringify(steps.trigger.event) }}

and let me know if that works?

where would i actually implement that code?

as in write it into pipedream

So in the Data field, do you see how you’re currently passing

{{steps.trigger.event}}

That’s passing the value of the JavaScript object steps.trigger.event . But you can pass any JavaScript expression within the {{ }}, so just replace the value you’re passing to the Data field with

{{ JSON.stringify(steps.trigger.event) }}

it worked

thank you very much!

great!

fantastic customer service :pray:

we’ll make a note to improve that action, it should be able to handle both strings and objects like you passed

good luck with the hackathon

(and let us know if you have any other questions)

One more question

The general idea of our API use is to connect Google Classroom and Adalo in such a way that when a teacher uploads an assignment to google classroom, the due date and assignment name are stored in an adalo database