Hello, I am calling in my scenario Perplexity module and telling him to give the required results in JSON format so I can easily parse them into the “Parse Json” make module. The problem is that somethimes Perplexity add ‘’’ sign before and after the required outputs, making the JSON parser send an error as he don’t recognize a JSON format.
I tried to ask in the JSON parser module to take as input a function which will replace this ‘’’ caracter with emptystring, so that he can process the data correctly and so he do.
The issue is sometimes perplexity respond correctly without the ‘’’ and sometimes he add them.
So: Is there a way that in my JSON parser module, I can put an IF function, that will depending on the perplexity output, either take the perplexity output as it is if there is no ‘’’ characters, or if there are, then do the replace function as i explained above.
Thanks for your supports.
regards
What you can try is to use the replace function with a regular expression. It will remove the " only if they appear at the beginning or end of the JSON doc.
Hello Benjamin, Thank your for your reply. I’m not sure in your regex if you include the ‘’’ sign, as it is not the same i see in your screen capture? also i’m not good at regex, so may be if you can just explain, i can understand what i have to change. Thanks. NB: Also I noticed that sometimes perplexity give the ‘’’ sometimes not.
It means that instead of mapping directly the result from Perplexity, you can use the replace function. It should look like this screenshot, except the variable 1.raw result from perplexity that has to be replaced by the output of Perplexity.
In the JSON string of your Parse JSON, directly copy/paste this:
{{replace(1.raw result from perplexity; "/^""|""$/g"; emptystring)}}
Then remove the 1.raw result from perplexity (that should be black&white)
And map the relevant output from Perplexity instead.
If you are still stuck, send me a little screenshot of your scenario and the configuration of your Parse JSON, and an output of Perplexity, to see what it looks like.