Sorry how description "Object() is more technically correct than {} but both will work." connected with the code a := Map(), b := Map(), c := Map(), d := Map(), e := Map(), f := Map()?a := Map(), b := Map(), c := Map(), d := Map(), e := Map(), f := Map() ; Object() is more technically correct than {} but both will work.
JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
Object() is for AHK v1 (just a mistake in the comments). Map() is for AHK v2. Map() and Object() in this context are almost the same, but for different versions of AHK.
« Portable AHK Installer » | « CallTipsForAll » | « All Scripts by TheArkive » | « TheArkive on GitHub »
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
This script is really useful for me! On the latest v2 alpha, I am experiencing one minor issue: All boolean values are loaded as a string (either "true" or "false")
I've narrowed it down to the fact that AHK v2 does not return true when you call IsNumber on the strings "true" and "false". Additionally, using the expression when var is the string "true" or "false" throws an exception because AHK thinks you're trying to assign a value to a protected variable.
I had to change that block of code to this:
Edit: Come to think of it, the "null" check nested within IsNumber likely doesn't work either... my .json files just don't have null values AFAIK.
I've narrowed it down to the fact that AHK v2 does not return true when you call IsNumber on the strings "true" and "false". Additionally, using the expression
Code: Select all
%var% + 0
I had to change that block of code to this:
Code: Select all
if IsNumber(val) {
if IsInteger(val)
val += 0
else if IsFloat(val)
val += 0
else if (val == "null")
val := ""
else if is_key {
pos--, next := "#"
continue
}
} else if (val == "true" || val == "false") {
val := (val == "true")
}
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
@bmcclure
Thanks for the report!
I'll make the change in the OP soon, and of course give you credit. I'm surprised i missed that one
Thanks for the report!
I'll make the change in the OP soon, and of course give you credit. I'm surprised i missed that one

« Portable AHK Installer » | « CallTipsForAll » | « All Scripts by TheArkive » | « TheArkive on GitHub »
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
Awesome, thank you!
Just to confirm, are you still working on the change or is it already done?
It looks like the change is in the OP, however it (and the "null" string check) are still nested within the IsNumber() conditional. I don't think those two checks will work right until they're moved out to the same level as that IsNumber conditional.
Just to confirm, are you still working on the change or is it already done?
It looks like the
Code: Select all
val := (val == "true")
Re: JSON - load and dump arrays to/from JSON - AHK v1/2 - 2020/10/10 - a122
@bmcclure
Yep you're right. Fixed.
I just removed the IsNumber() check, not needed since the other types are already checked.
Yep you're right. Fixed.
I just removed the IsNumber() check, not needed since the other types are already checked.
« Portable AHK Installer » | « CallTipsForAll » | « All Scripts by TheArkive » | « TheArkive on GitHub »
Return to “AutoHotkey v2 Scripts and Functions”
Who is online
Users browsing this forum: No registered users and 4 guests