Skip to content
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

Jxon use #8

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Jxon use #8

wants to merge 14 commits into from

Conversation

mapa4
Copy link

@mapa4 mapa4 commented Feb 5, 2017

Hi CocoBelgica,

I experimented your Jxon function, thanks for creating it.
I was wondering if I could use it with JSON navigation strings stored in an ini file.

If for example my code is :
/*
[JSON] ; .INI File
Key1=hello
Key2=foo.1
Key3=its.over
*/
json_str = {"hello":"world","its":{"over":"9000"},"foo":["bar"]}
j := Jxon_Load(json_str)
msgbox % j.hello ; test1-1 ok
msgbox % j["hello"] ; (using Key1 equivalent of the above) : test1-2 ok
msgbox % j.foo.1 ; ok
msgbox % j.foo[1] ; test2-1 ok
;msgbox % ; (using Key2 equivalent of the above) : test2-2 ?
msgbox % j.its.over ; test3-1 ok
;msgbox % ; (using Key3 equivalent of the above) : test3-2 ?

What would be the equivalent syntax for test2-2 and test3-2 based on test1-2 syntax ?

Thanks in advance.
Best regards.

- JSON.object.len() returning blank ("") if object{} is empty.
- JSON.object.Remove(): new v2 for-loop resets variable(s) (k, v) to their
  previous value(s), hence, function not working properly.
- JSON.object.Remove() now behaves like AHK's obj.Remove() except existing
  integer key(s) are not adjusted when an integer key(or range of integer keys)
  is removed. Return value is the same as AHK's obj.Remove().
starting pos in SubStr() during parsing of literal string(s).
 - 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).
- 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.
- parse():
  Changed parsing of true,false,null values -> no longer loops
  through each character to validate.
  Minor optimizations + code refactoring.
- Code refactored.
- Removed previously kept commented old code parts.
Rewrote some parts -> changes mostly taken from Json2.ahk(master branch).
@cocobelgica
Copy link
Owner

Apologies for the late response.

If you're storing the "path" as a string(dot-delimited) such as "foo.1" and "its.over", you can do something like:

path1 := StrSplit(Key2, ".")
MsgBox % j[path1*]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants