call to nonexistent function UMap()..
is this for reg v2 or _h?
Code: Select all
Y:=Yaml(text)
Y["users"][1]["_id"] ; btw this breaks using the example text string
Code: Select all
Y:=Yaml(text)
Y.users[1]._id
Code: Select all
json["included"][1]["progressiveStreams"][1]["bitRate"]
Code: Select all
m:=Map(1,2,3,4,5,6,7,8)
j:=EASYJSON(m)
MsgBox j.1
Class EASYJSON {
__New(json){
this.%""%:=json
}
__Get(k,v){
return IsObject(val:=this.%""%[IsNumber(k)?k+0:k]) ? EASYJSON(val) : val
}
}
I am aware of those yeah.HotKeyIt wrote: ↑21 Apr 2022, 07:29In v2 accessing properties and Items is separated and Map + Array have Items and Properties at the same time, also in obj.1 the key 1 is as a string and in obj[1] the key 1 is a number!
You can try somthing like this but will be only for reading and rather slow:Code: Select all
m:=Map(1,2,3,4,5,6,7,8) j:=EASYJSON(m) MsgBox j.1 Class EASYJSON { __New(json){ this.%""%:=json } __Get(k,v){ return IsObject(val:=this.%""%[IsNumber(k)?k+0:k]) ? EASYJSON(val) : val } }
I see how those could be a problem but I personally would program around those and map them to keys instead and make a note of that. I think the pros of having dot notation outweigh the few keywords that should be mapped to keys instead.
Code: Select all
case "video":
RegExMatch post["content"]["Metadata"], "Asset:(?<id>.*)", &media:=""
vidurl := mediaLib[media.id].url
imgurl := mediaLib[media.id].thumb
case "article":
vidurl := "none"
imgurl := post["content"]["lImage"]["attributes"][1]["vector"]["Url"]
. post["content"]["lImage"]["attributes"][1]["vector"]["art"][2]["Url"]
Code: Select all
post["content"]["lImage"]["attributes"][1]["vector"]["Url"]
Code: Select all
post.content.lImage.attributes[1].vector.Url
Code: Select all
obj_.DefineProp("CaseSense", {Value: value_})
MsgBox obj_.%"CaseSense"%
Code: Select all
MsgBox JSON_parse(FileRead("AutoHotkey_L releases.json"))[1]["assets"][1]["browser_download_url"]
MsgBox JSON_parse(FileRead("AutoHotkey_L releases.json"))[1].assets[1].browser_download_url
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
#Include Yaml.ahk
text:="
(
chlds:
-
a1title: 0301
-
a1title: 0301
-
a1title: 0301
)"
text2:="
(
chlds:
-
a1title: 0301
-
a1title: 0301
)"
y := Yaml(text) ; Load Yaml documents into objects
MsgBox Yaml(y,5) ; Dump objects back into Yaml
esc::ExitApp
/*
Error: Indentation problem.
Specifically: -
---- D:\work\14_scripts\AK2\Libs_v2_2\Yaml-ahkV2\Yaml-ahkV2\Yaml.ahk
226: If LL<_LL
227: If !I[LL]
▶ 228: Throw ValueError("Indentation problem.", 0, LF)
229: Else
229: L := I[LL]
The current thread will exit.
Show call stack »
*/