-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AHK v2 a108 code #21
Open
TheArkive
wants to merge
56
commits into
v2
Choose a base branch
from
master
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
AHK v2 a108 code #21
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- parse(): Improved validation of JSON source. Most (if all) common format errors are detected. As before, an exception is thrown. Code refactored. Added 'OutputNormal' class property to allow users to set whether returned object(s)/array(s) are sublclassed as JSON.object/JSON.array instance(s). Default is 'true' which returns instance(s) of JSON._object/JSON._array(notice the underscores) which are actually just normal AHK object(s) with no special behavior. - stringify(): A space is no longer added after a comma or colon if indent is not specified. Output is truly compact.
- parse(): Removed 'OutputNormal', '_object' and '_array' class properties. 'OutputNormal' has been replaced with 'jsonize' parameter. Defaults to 'false' which returns object(s) as normal/ordinary AHK object(s). Changed parsing of true,false,null values -> no longer loops through each character to validate. Minor optimizations + code refactoring. - stringify(): Fixed output for empty object(s) when indentation is specified. No longer checks if an object is an instance of JSON.object or JSON.array as this will cause erroneous output if the user modifies the object's contents prior stringification. Minor optimization + changed some variable names.
- Alternative to JSON.ahk. - Interface implemented as a function instead of a class. - Will work on both AHK v1.1 and v2.0-a - FOR v2.0-a -> A_AhkVersion >= v2.0-a049.
such as COM, Func, RegExMatch, File object(s). Fixed dumping bug when object has a custom enumerator.
range of integer keys, remaining integer keys are not adjusted. Will fix in next commit.
- New function names: Jxon_Load(), Jxon_Dump() - Added Jxon_Read() and Jxon_Write() -> for file read/write
literal strings are no longer extracted prior markup parsing. This allows passing of variable(if any) containing the JSON document as ByRef.
more descriptive and provide information on the line number, column number and character position of the invalid data/token.
them in the first place.
Jxon_Dump(): Improved error info if object key is invalid.
The fact that the block is reached means that the currently evaluated char/token must be either of these: '01234567890-tfn'. So to signal an error, 'next' must simply be neither of those.
General - [commit cc42d90] Improved string replacement routines. JSON.parse() - [commit b33db32] Changed from two-pass to single-pass method. - [commit c664a37] Simplified parsing of number(s), true, false and null. - [commit 315d6fe] Fixed a bug when validating next char after comma(,) in object. - [commit 46c262b] Improved exception handling w/ descriptive error messages.
- Lib is now AutoHotkey v1.1 and v2.0-a compatible - Added JSON.object.Delete() - similar to ObjDelete() - Removed JSON.object.Count() and JSON.object.Insert() - Array methods such as InsertAt/RemoveAt and Push/Pop are not implemented for JSON.object object(s). - Some changes here and there.
- Changed .parse() to .Load() - Changed .stringify() to .Dump() - For compatibility, call(s) to .parse()/.stringify() are casted to .Load()/.Dump() respectively.
Conform with ECMAScript's JSON.parse() and JSON.stringfy() specifications - Remove backward support for old Parse() and Stringify() methods - Remove JSON.Object and JSON.Array objects - Remove JSON.Load()'s 'jsonize' paramter - Add 'reviver' parameter to JSON.Load() - Add 'replacer' parameter to JSON.Dump() - Improve handling of array(s) during stringification process - Limit indentation(pretty-printing) to 10 characters - Add missing error message - Disable '/' escaping when stringifying
- Load(), remove static variable 'null'. This should make it AutoHotkey_H-compatible(untested). - Dump(), improve skipping of non-serializable objects such as ComObject, Func, BoundFunc, FileObject, RegExMatchObject, Property, etc. - Add JSON.Undefined for use within reviver/replacer functions
- Properties are not removed if the reviver function returns JSON.Undefined - When stringifying sparse arrays, Dump() overrides the returned value of the replacer function(when an empty element is passed) with 'null'. - Pass JSON.Undefined as value parameter to the replacer function if the current field is an empty field in a sparse array.
Previously math (value += 0) is applied on unquoted numerical values to "numerify" the numbers. As a side-effect, floating point values are sometimes altered based on A_FormatFloat. Returning the value as it appears in the document/text should be the behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I played around with the code in Jxon.ahk and got a working version for AHK v1 and v2 (a108). Some lines have to be toggled as commented / uncommented to get both AHK v1 and v2 functionality. Straight
{}
objects have been dropped in the AHK v2 bit. OnlyArrays()
andMaps()
are included.AHK v1 issues:
AHK v2 progress:
JXON.ahk.txt