Page 1 of 1

decodeURIcomponent to json

Posted: Mon Mar 21, 2022 10:24 am
by Dave23
Hi there,
I have a payload of data that I am getting from a webhook. The data needs to be decoded and parsed as a json.
Is there currently an app or away to do this within Switch using the current elements? or would this require a script to do this?
Thanks

Re: decodeURIcomponent to json

Posted: Mon Mar 21, 2022 12:17 pm
by freddyp
If the payload is JSON, you can attach it as an opaque dataset and use the JSON pickup app to convert it to XML. That is the short-term solution, but know that the Switch 2022 Spring release has native JSON support. In other words, you will be able to browse in the data structure of a JSON just like you can now in the data structure of an XML.

Re: decodeURIcomponent to json

Posted: Mon Mar 21, 2022 1:01 pm
by magnussandstrom
freddyp wrote: Mon Mar 21, 2022 12:17 pm .. but know that the Switch 2022 Spring release has native JSON support. In other words, you will be able to browse in the data structure of a JSON just like you can now in the data structure of an XML.
Great news!!

Re: decodeURIcomponent to json

Posted: Mon Mar 21, 2022 3:18 pm
by Dave23
Hi @freddyp, that is good news. Unfortunately the payload is of neither xml or json. When I copy the content in to an online JSON URL decoder it converts perfectly to a json. I'm hoping there is an easy way to do this?

Re: decodeURIcomponent to json

Posted: Tue Mar 22, 2022 9:33 am
by freddyp
In a normal webhook the payload is in the body of a POST and in that case there is no reason to URL encode it, but technically it is possible. Or does the webhook pass the information on the URL string as part of a GET? In that case URL encoding would be required.

So how is the URL-encoded JSON passed to the webhook? Send it to the Webhook element and show us what comes out.