No internet connection
  1. Home
  2. Questions

Parsing RawRequest Json

By isedwinr @isedwinr
    2022-06-01 05:59:48.588Z

    Hi,

    I'm trying to parse Json data from the TA webhook where the data is received from Jotform and is in the format below:

    The "Extract from Json" Action doesn't recognize the structure, nor did I have any luck converting it using the "Read Json document" Action.
    I tried a workaround to extract the values from the "RawRequest" string using "Find&Extract", but the "Look For" seems to think I entered a Regular Expression instead of text when I enter ' {"first" '

    Any idea how to solve this?
    {
    "formID": "XXXXXX",
    "submissionID": "XXXXXX",
    "webhookURL": "https://api.thinkautomation.com/addmessage?taid=XXXXXX",
    "ip": "XXXXXX",
    "formTitle": "2022",
    "pretty": "Hoofdgast:textbox_sample0 textbox_sample1, e-mail adres:john@example.com, (Mobiel) Nummer:textbox_sample3, Naam gast 1:textbox_sample4 textbox_sample5, Naam gast 2:textbox_sample6 textbox_sample7, Naam gast 3:textbox_sample8 textbox_sample9",
    "username": "XXXXXX",
    "rawRequest": "{"slug":"submit\/XXXXXX","input_language":"Nederlands","q3_hoofdgast":{"first":"textbox_sample0","last":"textbox_sample1"},"q4_emailAdres":"john@example.com","q10_mobielNummer":"textbox_sample3","q11_naam11":{"first":"textbox_sample4","last":"textbox_sample5"},"q12_naamGast":{"first":"textbox_sample6","last":"textbox_sample7"},"q14_naamGast14":{"first":"textbox_sample8","last":"textbox_sample9"},"preview":"true","path":"\/submit\/XXXXXX"}",
    "type": "WEB"
    }

    • 4 replies
    1. L
      Liam @liam
        2022-06-01 09:46:54.248Z

        I'm no JSON expert, but the problem with the JSON actions and this block is that the rawRequest section is getting flagged as invalid JSON, if you run it through a validator such as this: https://jsonformatter.curiousconcept.com/# for example.

        However, the standard "Extract Field" does work for me, I'm not sure what exactly you are trying to extract until, but this works as the Look For value

        1. I
          In reply toisedwinr:
          isedwinr @isedwinr
            2022-06-01 13:44:41.133Z

            Liam,

            owwww, I see what you mean but I now see when I paste the Json in this message it removes the "Json escape" characters.
            That's also why the validator went wrong I guess

            So to try again, this is the original Json in " Preformatted Text" ;-)

            {
              "formID": "XXXXX",
              "submissionID": "XXXXX",
              "webhookURL": "https://api.thinkautomation.com/addmessage?taid=XXXXX",
              "ip": "XXXXX",
              "formTitle": "XXXXX2022",
              "pretty": "Hoofdgast:textbox_sample0 textbox_sample1, e-mail adres:john@example.com, (Mobiel) Nummer:textbox_sample3, Naam gast 1:textbox_sample4 textbox_sample5, Naam gast 2:textbox_sample6 textbox_sample7, Naam gast 3:textbox_sample8 textbox_sample9",
              "username": "PortAll",
              "rawRequest": "{\"slug\":\"submit\\/XXXXX\",\"input_language\":\"Nederlands\",\"q3_hoofdgast\":{\"first\":\"textbox_sample0\",\"last\":\"textbox_sample1\"},\"q4_emailAdres\":\"john@example.com\",\"q10_mobielNummer\":\"textbox_sample3\",\"q11_naam11\":{\"first\":\"textbox_sample4\",\"last\":\"textbox_sample5\"},\"q12_naamGast\":{\"first\":\"textbox_sample6\",\"last\":\"textbox_sample7\"},\"q14_naamGast14\":{\"first\":\"textbox_sample8\",\"last\":\"textbox_sample9\"},\"preview\":\"true\",\"path\":\"\\/submit\\/XXXXX\"}",
              "type": "WEB"
            }
            
            

            BTW ofcourse I can extract the field by removing these escape characters *thanks for that) but i'd like to have a more elegant solution.

            1. M
              In reply toisedwinr:
              Mark Carpenter @mark.carpenter
                2022-06-03 13:07:41.313Z

                This one line set variable seems to work. The only escapes remaining in the resulting variable are for the / in "slug" and "path":

                Rawbody = %func%:JsonValue(%MsgBody%,"rawRequest")

                1. Iisedwinr @isedwinr
                    2022-06-04 12:34:42.655Z

                    That's a great idea. Thanks a lot @mark.carpenter !