decodeURIcomponent to json

Post Reply
Dave23
Member
Posts: 41
Joined: Thu Oct 12, 2017 4:42 pm

decodeURIcomponent to json

Post 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
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: decodeURIcomponent to json

Post 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.
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: decodeURIcomponent to json

Post 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!!
Dave23
Member
Posts: 41
Joined: Thu Oct 12, 2017 4:42 pm

Re: decodeURIcomponent to json

Post 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?
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: decodeURIcomponent to json

Post 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.
Post Reply