Accessing object data {} returned from a WebRequest() fuction

 

Hi, hoping to get some help with this. Please see my code below.

So I have managed to return the data I want as shown below from the first "Print(_result);" I have the raw data as a returned object:

However I was wanting to access specific parts of this object. I would have expected "Print(result[0].update_id);" to return "1234" but I just get the error "struct or class type expected". Specifically from this data I need "message_id" and "text". Any advice?


{
"ok": true,
"result": [
                {
                "update_id": 1234,
                "message":      {
                                "message_id": 17, 
                                "from":         {
                                                "id": 1234, "is_bot": false, "first_name": "David", "last_name": "xxx", 
                                                "username": "xxx", "language_code": "en"
                                                },

                                "chat": {
                                        "id": 1234 ,
                                        "first_name": "David",
                                        "last_name": "xxx",
                                        "username": "xxx",
                                        "type": "private"
                                        },
                                "date": 1234, "text": "Hi"
                                }
                }
        ]
}



#property copyright 
#property link      
#property version   "1.00"
#property strict


void OnInit()
   {
   string url = "https://api.telegram.org/****/getUpdates?offset=0";
   int timeout = 5000;
   char post[], result[];
   string headers, _result;
   
   WebRequest("GET", url, NULL, NULL, timeout, post, 0, result, headers);
   _result = CharArrayToString(result);
   Print(_result);
   //Print(result[0].update_id);
   }


void OnTick()
   {

   }
 
This looks like JSON, you need to feed the buffer into a json parser and then you navigate through the obtained structure.
 
lippmaje:
This looks like JSON, you need to feed the buffer into a json parser and then you navigate through the obtained structure.

Ok thanks.

Reason: