Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  Form a JSON using dynamic variable values

    Posted 10-14-2024 12:50

    Hello Everyone,

    I tried to form a JSON using JsonParse method like below.

    JsonParse("{ \"ANI\": Call.ANI, \"Data\": Task.Data1, \"DNIS\": Call.CalledAddressOriginal, \"ConversationId\": Call.ConversationId }")

    During the runtime i am getting error. How can i pass the Variables values to Json object? Please Assist on this.


    #API/Integrations
    #ArchitectureandDesign
    #Routing(ACD/IVR)
    #Telephony

    ------------------------------
    Regards,
    Shenbagamoorthy B
    TechLead
    Pointel Inc.,
    ------------------------------


  • 2.  RE: Form a JSON using dynamic variable values

    Posted 10-15-2024 08:31

    You are making a simple fault: The variables you are trying to add to the JSON are strings as well - so to parse them as JSON, they also need to be strings.
    Like this: JsonParse("{ \"ANI\": \" + Call.ANI + "\"}") 



    ------------------------------
    Michael Lukoschek
    NA
    ------------------------------



  • 3.  RE: Form a JSON using dynamic variable values

    Posted 10-15-2024 12:15

    Dear Michael,

    Thank you for your Answer. I tried same thing in to Architect Update data block JSON Variable. I got the Output like {"ANI":+Call.ANI+}. I want exact ANI value. Kindly Assist on this.



    ------------------------------
    Regards,
    Shenbagamoorthy B
    TechLead
    Pointel Inc.,
    ------------------------------



  • 4.  RE: Form a JSON using dynamic variable values
    Best Answer

    Posted 10-16-2024 02:12

    Hi Shengabamoorthy,

    Sorry - I did answer a bit too fast and made a fault myself. Masking quotes in this kind of expressions can be a bit tricky. 
    The correct expressions should be: JsonParse("{ \"ANI\": \"" + Call.ANI + "\"}") 
    The second quote before "+Call.ANI" ends the string to enter the variable, while the first (masked one) starts the string in the resulting JSON expression. 
    You need to understand this general concept. 

    Best regards
    Michael



    ------------------------------
    Michael Lukoschek
    NA
    ------------------------------



  • 5.  RE: Form a JSON using dynamic variable values

    Posted 10-16-2024 07:42

    Dear Michael Lukoschek,

    Thank you so much. Its working for me. Now I am able to form JSON using above syntax.



    ------------------------------
    Regards,
    Shenbagamoorthy B
    TechLead
    Pointel Inc.,
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources