Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2022-08-03 13:59:30

karlitoxz
Member
Registered: 2021-02-10
Posts: 16

Get data from an array without foreach

Good morning, I am getting data from an api, in this way:

{
    "emails": {
        "email1": "***.com",
        "email2": "***.com"
    },
    "status": "success"
}


From a bot and in the "Send Text" option and with the help of foreach it prints me correctly.


    {foreach=content_1}
        - {args.item}
    {/foreach}

How could I access the mail "email 1" without being in a foreach? I have tried things like:


After using "update current chat" -> Set chat variable [not visible by operator] -> {"emails":"{content_1}"}

{args.chat.chat_variables_array.emails.0}
{args.chat.chat_variables_array.emails.*}
{args.chat.chat_variables_array.emails:email1}
{args.chat.chat_variables_array.emails.email1}
{args.chat.chat_variables_array.emails.0.email1}


But I have not been successful, could someone guide me. Thanks in advance.

Last edited by karlitoxz (2022-08-03 20:42:57)

Offline

#2 2022-08-04 19:04:14

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Get data from an array without foreach

You should use that syntax in output parsing in your rest api call just. Afterwad it would
be like content_1 or content_2

Offline

#3 2022-08-04 20:34:35

karlitoxz
Member
Registered: 2021-02-10
Posts: 16

Re: Get data from an array without foreach

Ok remdex, what happens is that I already have the other "content_x" used by other data that comes from that same API; This is why I was looking at how to use the first "content_1" as an array but use the data without the help of a foreach


the idea I have is to use the first email "email1" to store the original email and the other to obfuscate the email "email2" and display it in the bot but masked "***.com"

Offline

#4 2022-08-05 02:53:16

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Get data from an array without foreach

I see your point. I ques the only way to do it would be extend Rest API call. So there would be something like content_1_array.xxx support. You can try actually extend lhc, I would accept pull request for that. As I’m in holidays not much I can do now, in amy case it would be just paid improvement for a few hours…

Offline

Board footer