Genesys Cloud - Main

 View Only

Sign Up

  • 1.  Getting error to Parse with GetJsonObjectProperty()

    Posted 11 days ago
    Edited by Subhajit Podder 11 days ago

    I want to parse a JSON object which contains an array of questions and each question has an array of answers which I want to parse dynamically. 

    For that I am trying to parse the entire questions Array Object with GetJsonObjectProperty(JsonParse(Flow.SurveyFormDetails), "questions") and then iterate through each element to fetch the question and display. Flow.SurveyFormDetails - Stores the entire JSON object attached. Same I need to do to fetch the answer list for each question with another inner loop. 

    I am taking this complex approach because I could not use "*" to parse list of questions with the JSON functions in Architect.

    I am getting the below error every time -  "Update Statements → Flow.Questions[4] → [4] → getjsonobjectproperty → jsonObject". Can you please assist me to resolve that?

    Note: The object may have multiple question groups too so I want to know the approach to handle the complex nested array objects inside a JSON dynamically.

    Below is the JSON body - 

    {
      "id": "5de59386-5d93-4d30-bfb4-154a1c00936b",
      "name": "Sandisk Chat Survey Form",
      "modifiedDate": "2026-02-09T13:20:16.451Z",
      "published": true,
      "disabled": false,
      "contextId": "7d1697b9-a5e5-4585-8715-36d4f9ee4891",
      "language": "en-US",
      "questionGroups": [
        {
          "id": "939f00f2-e9e1-4b27-9b17-7803d7223062",
          "contextId": "c42a36d9-76a4-4c65-ba6a-a361fa086ccc",
          "name": "Customer's Overall Experience",
          "type": "questionGroup",
          "naEnabled": false,
          "questions": [
            {
              "id": "a648e299-c215-42b0-8643-c131819c425c",
              "contextId": "863bcfe6-2a43-4164-8809-4056b0757fef",
              "text": "Has your question been answered?",
              "helpText": "",
              "type": "multipleChoiceQuestion",
              "naEnabled": false,
              "answerOptions": [
                {
                  "id": "7f6c6ce9-da28-4378-9668-a59bc7e59eb3",
                  "contextId": "745fea04-acc9-4ede-a298-38493d150d61",
                  "text": "Yes",
                  "value": 1
                },
                {
                  "id": "4364bdc3-21e5-47fb-83df-a694b9edb46f",
                  "contextId": "de727d92-d9f2-475e-9ec0-d0f8a870b7a1",
                  "text": "No",
                  "value": 0
                }
              ]
            },
            {
              "id": "dc26745d-8ba0-4fd8-9f1f-c805839e558a",
              "contextId": "fe439290-1c8f-4f94-99aa-999547daf8f2",
              "text": "How would you rate your overall experience?",
              "helpText": "",
              "type": "multipleChoiceQuestion",
              "naEnabled": false,
              "answerOptions": [
                {
                  "id": "4c5ecf0a-671d-4c20-8030-06e9b080549d",
                  "contextId": "4a3416fe-fb4f-46fc-a6cb-50011c5d16f2",
                  "text": "Very Dissatisfied ",
                  "value": 1
                },
                {
                  "id": "be310776-1e3c-41fc-92b1-f1a76aee5cca",
                  "contextId": "bbce241b-bd37-4a34-a25c-df2d51203564",
                  "text": "Dissatisfied ",
                  "value": 2
                },
                {
                  "id": "e8581b07-0792-428d-811f-599a640c9baa",
                  "contextId": "207273b0-8d92-40a9-b717-6d5c38e79128",
                  "text": "Neutral ",
                  "value": 3
                },
                {
                  "id": "686a381d-6c55-44d0-b834-bc7ebc8caa55",
                  "contextId": "00c4005e-2b96-4d26-bc7e-773e644e1757",
                  "text": "Satisfied",
                  "value": 4
                },
                {
                  "id": "54b26a44-8557-4123-a6d9-7521502bf4c1",
                  "contextId": "0b510c6d-4173-4122-97af-4fbe29df8d9f",
                  "text": "Very Satisfied",
                  "value": 5
                }
              ]
            }
          ]
        }
      ],
      "selfUri": "/api/v2/quality/publishedforms/surveys/5de59386-5d93-4d30-bfb4-154a1c00936b"
    }


    #ArchitectandDesign
    #Implementation

    ------------------------------
    Subhajit Podder
    NA
    ------------------------------



  • 2.  RE: Getting error to Parse with GetJsonObjectProperty()
    Best Answer

    Posted 11 days ago
    Edited by Jason Kleitz 10 days ago

    Hi Subhajit, how are you?

    I could be completely wrong, since I'm not 100% sure on what steps you are taking, etc.

    But by looking at your Json and at your explanation, it seems to me that you should not be trying to access the "questions" array, because this array is not part of the Json's root level (first level).

    What you have to access initially would be the first array (questionGroups) which is on root level, and then when you are inside that level, you can access the "questions" array.

    So using your expression as an example, I believe it would look something like this:

    GetJsonObjectProperty(JsonParse(Flow.SurveyFormDetails).questionGroups[0], "questions")

    Edited: Also, I just edited this comment to include the "[0]" above, which I had forgotten. Take into consideration that what I'm showing above is just checking the first index of "questionGroups", but you can build the dynamically to check each index. (Have this in a loop, access each index, and from each index you can access all questions on the questions array, etc.)

    But just so you know, I didn't test the expression above, so I'm not 100% sure it works in the way I described. But check if it helps!



    ------------------------------
    Marcello Jabur
    ------------------------------