In my http request to access an important API, I need to send in a JSON object with header: { x-api-key : "myapikey"}
I've always built the object in AHK first and then parsed it into JSON with a function.
New AHKv2 decided that 'x-api-key' is an 'Invalid property name in object literal'.
Come on... that's crazy. I need to be able to make an object with a '-' in the key name. Can this be fixed or will I be forever using AHK v1?
I'm doing everything I can to make a workaround... still no luck... It's giving me errors that make zero sense.
Error: This value of type "Object" has no property named "__Item".
003: p := {}
▶ 004: p["x-api-key"] := 1
006: MsgBox(p["x-api-key"])
008: ExitApp()
v2 object issues Topic is solved
Re: v2 object issues
If there's no fix, can this be moved to AHK v2 bugs. This is serious. I can't use v2 until this is fixed.
It's frustrating to run into an error like this after spending 20hrs learning the new system and rewriting key functions in the new syntax, only to find I can't use any of this for my primary use case because of some overly strict syntax requirements.
It's frustrating to run into an error like this after spending 20hrs learning the new system and rewriting key functions in the new syntax, only to find I can't use any of this for my primary use case because of some overly strict syntax requirements.
-
- Posts: 144
- Joined: 01 Feb 2017, 22:57
Re: v2 object issues Topic is solved
Use Map (see: https://www.autohotkey.com/docs/v2/v2-changes.htm#objects-misc)
Code: Select all
p := Map()
p["x-api-key"] := 1
006: MsgBox(p["x-api-key"])
008: ExitApp()
Re: v2 object issues
Okay the workaround for map is working thanks. It's too bad I can't use the regular object notation though { k : v }, I'm going to have to rewrite a bunch of code.
-
- Posts: 144
- Joined: 01 Feb 2017, 22:57
Re: v2 object issues
Yes, this is a big part of the process of converting from v1 to v2. But IMO it's worth it. It makes the code less prone to breaking.
For previous discussions see viewtopic.php?t=67213&start=40
For previous discussions see viewtopic.php?t=67213&start=40
Who is online
Users browsing this forum: diegg1739, emp00, WarlordAkamu67 and 39 guests