Code Monkey home page Code Monkey logo

autohotkey-json's People

Contributors

cocobelgica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autohotkey-json's Issues

one more

line 17 generates the last of three errors. Apparently Instr can't handle anything besides numeric literals or a variable. So the part -(StrLen(src)-pos+1) should be replaced by tmp, which should be filled on the line before

JSON.Dump is converting diacritics to different encoding

input_string := [{"city": "Montréal"}, {"city": "Vancouver"}]
cities := JSON.Load( input_string )
;;;
output_string := JSON.Dump( cities )
MsgBox, %output_string%

Result:

[{"city": "Montr\u00e9al"}, {"city": "Vancouver"}] 

It has converted é to \u00e9

Why? How can I avoid that?

Please add some more meta info

Hi, could you please add the url to this repo right into the script's body and some email contact of yours (as the author) as well as the version and timestamp of latest change.
This would be handy: I use helluva ton of scripts and libs and I don't always remember where I took what from. And it's a PitA to check for scripts/libs updates, when a lib lacks that metainfo.

good work

There is no issue. I only want to say thank you! What a comfortable tool I use.

How to preserve original order?

I am using this library to pretty print the JSON. But it is order is changed alphabetically.
How to preserve the original order?

How can I force my (hex) object property names to be stored as strings rather than be converted to decimals?

I'm storing a dictionary-like structure where I need to check if a color exists in a large list of colors. Best way to do that is like if (colors["0x680000"]) so I generate an object like that but I need to save the object, so I export to JSON. Problem is, during the export, the hex values are treated as numbers (even though they're property names, and could probably safely be treated as strings) so they're converted to decimal. I need to figure out a way to store the object keys as strings rather than numbers so they stay in the format "0x680000" : {} in the JSON file.

Publishing AutoHotkey-JSON as an ahkpm package?

Hi @cocobelgica. I'm wondering if you'd be interested in publishing AutoHotkey-JSON as an ahkpm package?

ahkpm is a package manager built specifically for AutoHotkey libraries.

I've written a guide on how to publish ahkpm packages and it likely wouldn't take much time at all.

The main thing I noticed that you might need to change is to start tagging new versions with the appropriate semantic version number. e.g. git tag 1.3.18.

I'd be happy to open up a PR adding the ahkpm.json file if you're interested.

Cannot run more than 2 function in a script

In my script i have 2 JSON.Load() function, the 1st one works and the 2nd don't. Similar to JSON.Dump... If i use more than 1 JSON function then all except the first one wont work.

Example:
content is a json string
json := JSON.Load(content)

invoice := json.invoice
msgbox, % invoice.Length () ; -> this work, shows the right length

line := StrSplit(sp, " ")
new := {}
new.sp := line[1]
new.sl := line[2]
view := JSON.Dump(new)
msgbox, % view ; -> this dont work, doesnt show anything


if i delete this line: json := JSON.Load(content)
then the JSON.Dump work

Thank you.

Numeric values get saved not as strings, but as null/true/false

STR:

  1. Run this script
  2. Fill "name" = 2 and "default route" = 3.
  3. Hit 'Save' button and save the data into an external file in JSON.
  4. Open that file (or drag'n'drop it onto the script).

Actual result:
2 and 3 got transformed to 'null'.

Expected result:
They should get saved as strings.

1 and 0 get transformed to 'true' and 'false' respectively.

JSON.Load returns non-iterable object on large input size

When I have a JSON string where the sum of the length of all keys is very large (for my object layout, a list of objects, it is somewhere over 10 000 characters, for flat object it should be higher), the result of JSON.Load is an object that cannot be iterated with the following construct

for k, v in object {
}

but if I check the capacity of the object it is 60.

Probably it is a limitation of ahk, as I do not see any obvious problem in your code.
How large can objects grow in ahk?

Specify V2 compatibility

The current code is not compatible with the most recent v2 build. Lines 239 and 279 would need to get rid of the % as expressions are standard now.

val true/false conversion

Jxon_Load:

; in v1.1, true,false,A_PtrSize,A_IsUnicode,A_Index,A_EventInfo,
; SOMETIMES return strings due to certain optimizations. Since it
; is just 'SOMETIMES', numerify to be consistent w/ v2.0-a
else if (val == "true" || val == "false")
val := %value% + 0

Shouldn't %value% be %val%? This line caused an execution error for me in AHKv2

distinction between true/false and 1/0 not preserved

The parser consumes true and false but then dumps them as 1 and 0.

This is an issue in JSON strings that include both true/false and 1/0 values that are intended to represent different data types (boolean vs. numeric).

Technically this behavior makes sense if your program is fully insulated in AHK, because AHK stores and represents these values the same way internally, but if you're sharing the JSON file with other applications, the distinction between true/false and 1/0 can become meaningful.

The code change made in response to issue #4 is tangentially related.

Issues with /

How can I access objects with a / in the name?

"test/slash": "good",

Maybe I'm doing something wrong.

AHK won't load my script when I try to include JSON.ahk

using AHK [1.1.35.00]
when I have this line:
#Include <JSON>
at the top of my ahk script I get an error when trying to load it, saying Error: Continuation section too long.
the error box gives me Line Text: which points to line 27 in JSON.ahk file.
I looked at this line and it is extremely long.

How can I work around this?

I know there is a continuation line section in the AHK documentation but it's way above my head and I don't understand enough to go messing around with myself.

telegram unicode emoji messages

Received JSON:
{"ok":true,"result":[{"update_id":91411951,"message":{"message_id":17826,"from":{"id":[Removed],"is_bot":false,"first_name":"[Removed]","last_name":"[Removed]","username":"[Removed]","language_code":"en"},"chat":{"id":[Removed],"first_name":"[Removed]","last_name":"[Removed]","username":"[Removed]","type":"private"},"date":1545984163,"text":"\ud83d\ude00"}}]}

The emoji sent is U+1F600 😀

Parsing this with
Update := JSON.Load(Json)

When i try to get Update.result[1].message.text
it returns ?0

is there a way to make it not parse unicode?

[suggestion] option to use other object factory e.g. Scripting.Dictionary wrapper

What a custom object factory can solve:

  • case sensitivity. The default AHK object is not, but JSON specs is.
  • preservation of order. The default AHK object auto-sorts alphabetically.

Implementing:

Add a static ObjectFactory property to JSON class, defaulting to Object. Every time Load creates a new object, it uses the ObjectFactory value. If it has a __Class property it calls new ObjectFactory, otherwise it just calls ObjectFactory().

To set their own object factories users simply set the property to a custom class that is object-like i.e. it implements key Object methods such as HasKey and _NewEnum that JSON class uses. One particular example is this Scripting.Dictionary class wrapper: forum link

I have successfully implemented this in a keyvalue parser library I'm using. I haven't shipped anything that uses it yet... but soon...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.