Genesys CTI User Forum
Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: deadmeat on April 24, 2017, 04:03:47 PM
-
Hello guys, hope everybody is doing good.
Can anyone share the format of list variable in IRD ? I've searched documentation but unfortunately without result.
Should it be key1:value1,key2:value2
or {key1=value1;key2=value2}
or something like that ? If anybody knows the answer it would very appreciable.
-
try: key1:value1|key2:value2|key3:value3
-
LIST variable is just regular KVList (exactly the same data that presents call attached data for example).
There are no literals of type LIST.
Instead strings in some formats can be converted into LIST values (with function like KVListFromString, etc or just by assigning string to LIST variable -
in such case compiler implicitly add code invoking converting function before assignment).
Conversion understand few formats including:
- key-value string like key1:value1|key2:value2|key3:value3|key4.subkey1:value4|....
- json, like {"key1":"value1", "key2":someNumber}
-
Thanks for the replies guys. key1:value1|key2:value2 worked fine. Earlier tried to feed json to list type variable but afterwards URS couldn't iterate on it correctly. Now it's fine.
[code]
11:26:29.398_H_I_008202976a56d521 [08:08] OK InfoMessage (200) is received from server ##HTTPSERVER, refid=12419970, hint=http
HTTPBody {"success":true,"lastCellId":"24853","lac":1506,"currentRegion":"Khatai"}
11:26:29.398_I_I_008202976a56d521 [09:05] >>>>>>>>>>>>resume interp(0), func:GetHttpRequestInfo
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "{"success":true,"lastCellId":"24853","lac":1506,"currentRegion":"Khatai"}"
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "{success:true,lastCellId:24853,lac:1506,currentRegion:Khatai}"
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "success:true,lastCellId:24853,lac:1506,currentRegion:Khatai}"
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "success:true,lastCellId:24853,lac:1506,currentRegion:Khatai"
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "success:true,lastCellId:24853,lac:1506,currentRegion:Khatai"
_I_I_008202976a56d521 [09:04] ASSIGN: strReturnedValue(LOCAL) <- STRING: "success:true|lastCellId:24853|lac:1506|currentRegion:Khatai"
_I_I_008202976a56d521 [09:04] ASSIGN: lstReturnedValue(LOCAL) <- LIST: success:true|lastCellId:24853|lac:1506|currentRegion:Khatai
_I_I_008202976a56d521 [09:04] ASSIGN: intCounter(LOCAL) <- INTEGER: 1
_I_I_008202976a56d521 [09:04] ASSIGN: strCurrentIteration(LOCAL) <- STRING: "true"
11:26:29.398 Int 22000 Current iteration is: true
_I_I_008202976a56d521 [09:04] ASSIGN: intCounter(LOCAL) <- INTEGER: 2
_I_I_008202976a56d521 [09:04] ASSIGN: strCurrentIteration(LOCAL) <- STRING: "24853"
11:26:29.398 Int 22000 Current iteration is: 24853
_I_I_008202976a56d521 [09:04] ASSIGN: intCounter(LOCAL) <- INTEGER: 3
_I_I_008202976a56d521 [09:04] ASSIGN: strCurrentIteration(LOCAL) <- STRING: "1506"
11:26:29.398 Int 22000 Current iteration is: 1506
_I_I_008202976a56d521 [09:04] ASSIGN: intCounter(LOCAL) <- INTEGER: 4
_I_I_008202976a56d521 [09:04] ASSIGN: strCurrentIteration(LOCAL) <- STRING: "Khatai"
[/code]
-
I know this is pretty old but, I have some comments about it
var_result get the WS call result in JSON format as:
[font=courier]var_result =
{
"message": "Recipient updated",
"smart_name": "APPLY",
"vb_url": "https://app.theresult.com/a/2255ddaa",
"abc_group": "Itt"
} [/font]
To convert it to a LIST:
[font=courier]v_kvlist = KVListFromJSONEx[var_result,0][/font]
Is updated as:
[font=courier]v_kvlist=message:Recipient updated|smart_name:APPLY|vb_url:https://app.theresult.com/a/2255ddaa|abc_group:Itt[/font]
Then you can assign variables or UData from the LIST as:
[font=courier]v_smart_name=KVListGetStringValue[v_kvlist,'smart_name']
Update['message',KVListGetStringValue[v_kvlist,'message']
Update[KVListGetKey[v_kvlist,1],KVListGetStringValue[v_kvlist,KVListGetKey[v_kvlist,1]]]
This works better, for complex JSON
for (i=1;i<KVListGetSize[var_kvlist];i++){
key=ListGetKey[var_kvlist,var_loop]
value=ListGetString[var_kvlist,var_loop]
Update[key,value]
}
[/font]
etc.
[code]
{
"totalSize":1,
"done":true,
"records":[
{
"attributes":{
"type":"typeA",
"url":"http://google.com/?q=object"
},
"Id":"889939392AA3",
"Alias":"auser",
"Registration_Date":"2022-01-01",
"Owner":{
"attributes":{
"type":"User",
"url":"http://srm.com/owner/aADR3wwAAB"
},
"Name":"Juan Perez"
},
"Scheduled":null,
"Explorer":"ABC"
}
]
}
var_TempKV(LOCAL) <- STRING[1,424]: "totalSize:1|done:1|records.#0.attributes.type:typeA|records.#0.attributes.url:http://google.com/?q=object|records.#0.Id: 889939392AA3 |records.#0.Alias:ssstoibe|records.#0.Registration_Date:2022-01-01|records.#0.Owner.attributes.type:User|records.#0.Owner.attributes.url:http://srm.com/owner/aADR3wwAAB|records.#0.Owner.Name:Juan Perez|records.#0.Explorer:ABC"[/code]
-
@antoni , what is the IRD version when you can use KVListFromJSONEx function?
I have been searching in doc and release notes and I have found no response.
-
Mentioned function is available by default in IRD, but it is not documented. All available functions you can find in compiler.dat under IRD installation folder
-
wow! I didn't know that!
I guess I didn't have the correct version because I get unknown error with the following json string.
Do you know why URS doesn't parse it to a LIST?
[code]
_I_I_006f030c0f8110d2 [09:04] ASSIGN: v_context(LOCAL) <- STRING[2,76]: "{'key1':'value1','key2':'value2','key3':'value3'}"
_I_E_006f030c0f8110d2 [09:04] error in strategy: 0001 Unknown error (KVListFromJSONEx)
[/code]
I answer myself
The JSON string need double quotes:
[code]
_I_I_006f030c0f8110d4 [09:04] ASSIGN: v_context(LOCAL) <- STRING[2,76]: "{"key1":"value1","key2":"value2","key3":"value3"}"
_I_I_006f030c0f8110d4 [09:04] ASSIGN: v_kvlist(LOCAL) <- STRING[1,62]: "key1:value1|key2:value2|key3:value3"
[/code]
Thank you!!!