Need help with a text formatted JSON

Hey guys ! Hope you’re all doing well !

I’m currently working on integrating Qencode’s API to transcode videos for my platform.

Everything’s working fine for the transcoding. However, I encounter an issue when receiving callbacks (webhooks) related to the transcoding job.

I am supposed to receive 2 callbacks by job, the first saying that the jobs is “transcoding”, and the second to tell me that the job is “completed”.

On top of that, the callback is also sending me the Duration of the videos, which i’d like to save.

The problem is that the data I received is text formatted, and i’m struggling to find a way to extract the Status parameter and the Duration parameter.

Here’s the setup of my Backend Workflow :

And here is an example of the raw data I receive :

    "status": "{\"status\": \"encoding\", \"videos\": [], \"status_url\": \"\", \"percent\": 0, \"source_size\": 2.5034685134887695, \"audios\": [], \"duration\": 10.044, \"error_description\": null, \"error\": 0, \"images\": [], \"api_version\": \"v1\"}",
    "callback_type": "task",
    "task_token": "c4a1b9d17b3fcb711ec9f427b40f86e4",
    "event": "queued",
    "payload": "null"

The issue is with the Status parameter. I would like to be able to extract the Status (which in this example is “Encoding”) as well as the duration of the video (which in this case is 10.044).

I’ve tried multiple regex (given by Chat GPT and Auto Regex), but nothing worked.

Any idea on what I could do ?

PS : this needs to be done in the backend of my app

It looks like a nested JSON field.

You could send the status field to another api workflow to have that parsed in the backend but if you want to keep it simple and use regex you’ll need 2 actions.

First is to do find and replace all \" with a blank. Then you can try this regex (?<=status: )([^,]*) to grab the value after status. Replace status with whatever key you need.

1 Like

Gotcha !

I tried your first solution (I find it less complex than regex :grin:) and it worked imediatly !

Thanks for your help :slight_smile:

1 Like