Array.Push_add_key_amd_value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inseption86
Posts: 203
Joined: 19 Apr 2018, 00:24

Array.Push_add_key_amd_value

27 Sep 2021, 15:21

Good evening, how do I add a key and value to an array? I_want add obj.results[A_Index].text and obj.results[A_Index].id

Code: Select all

Array_RequestTyp := []
obj := JSON.Parse(HTTP.ResponseText)
 loop, % obj.count
   Array_RequestTyp.Push(obj.results[A_Index].text) 

for key, element_RequestTyp in Array_RequestTyp
  MsgBox % key "_" element_RequestTyp


User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Array.Push_add_key_amd_value

27 Sep 2021, 15:34

I did not try it, but it might be like this.

Code: Select all

For each, item in obj.results
 Array_RequestTyp.Push(item.text)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Array.Push_add_key_amd_value

27 Sep 2021, 20:05

Code: Select all

Array_RequestTyp.Push({ (obj.results[A_Index].id): obj.results[A_Index].text })

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 228 guests