Jump to content

A Non-Strict JSON UDF (JSMN)


Recommended Posts

@jugador You seem offended, sorry. But I wasn't suggesting that your UDF is malicious, I was simply pointing out the fact that it is not secure.

As per my understanding, you use Microsoft's JScript engine to parse JSON by passing it as input to your own function, but the input is not sanitized to protect against arbitrary code, am I right?

A malicious JSON payload might contain code within the JSON or even outside it which is executed without the user's or script author's knowledge. It is important that the JSON input is sanitized because it is directly being injected as code which is run.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
  • Replies 335
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Introduction JSON (Javascript Object Notation) is a popular data-interchange format and supported by a lot of script languages. On AutoIt, there is already a >JSON UDF written by Gabriel Boehme.

Thanks. I didn't realize that the JSON Arrays were "just arrays." Solution provided below for others. #Include "JSon.au3" Local $Json = '{"name":"John","cars":[ "Ford", "BMW", "

Unfortunately, without a compelling reason, I have no intention of doing any pull requests or otherwise doing any of your scripting for you.  You're welcome anyway...  If you are interested in le

Posted Images

  • Developers

@TheDcoder,

Isn't the same true for Compiled script by definition with the encoded script being in the PE header

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers
4 hours ago, TheDcoder said:

Are we talking about compiled AutoIt scripts? If so I don't think I understand, please explain

Yes ....  and no, not up for further discussion in the open forum. My point is that this talk about code injection is somewhat far-fetched. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
5 minutes ago, Jos said:

My point is that this talk about code injection is somewhat far-fetched. ;) 

How so? It only takes one malicious JSON payload to exploit. And security by obscurity is never a good idea :)

7 minutes ago, Jos said:

Yes ....  and no, not up for further discussion in the open forum.

I don't see the attack vector in the context of an compiled AutoIt script. Unless you mean the script itself can be malicious? That's not what I was focusing on. Even a genuine script can be used by a malicious 3rd-party who just has the ability to pass on JSON to the script, such as a remote web server.

I took the liberty to clarify my points a bit in this post as I was going to reply anyway, hope you don't mind :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
Posted (edited)
On 7/1/2022 at 5:39 PM, Mateocedillo said:

Can you speed up the processing speed on long JSONs that contains much items?

The short answer is "most likely yes".  Without more information, there's really no better answer that doesn't include a bunch of speculation and assumptions.  If you want better answers, then learn how to ask better questions.  The more detailed and specific your questions and/or requests are, the more accurate the responses will most likely be.

You appear to be asking whether there is a way to speed up the code that you have written.  Seriously, how do you expect anyone to be able to answer that question without seeing your script or a script that accurately shows the logic that you are using, some sample JSON data, and a detailed description of the expected results you are trying to gather from that sample data?

JSMN, which is the JSON parsing engine that the json.au3 UDF lib is built around, is one of the fastest parsing engines around.  So I seriously doubt that any performance issues with your script are related to the functions in the UDF lib.  The most likely cause of your performance issues is the logic you are using to get the data or information that you want from the JSON.  As you've read, there are multiple tools & UDF's available for parsing (and processing) JSON.  If you are primarily wanting to pluck (parse) out data values, then I'm sure that the json.au3 UDF can do it as fast and efficiently as most any other JSON parsing engine.  If you need to gather more than just data, meaning you need to gather information (like sums, averages, counts/stats, etc.), add/delete/modify JSON values or objects, or reformat/splice/extract JSON structures, then I would suggest a tool like jq.  Some might even suggest parsing JSON using regular expressions, which may be very fast but (in my opinion) not as reliable, unless you have full control over the JSON being used as input (the order of the JSON data AND and its formatting).

 

On 7/1/2022 at 5:39 PM, Mateocedillo said:

I have the latest dependency (2021.11.06)

I'm not sure what you meant by this.  If you are referring to the latest version of the json.au3 UDF library, then it is 2021.11.20 not 2021.11.06.  You can find it near the bottom of the 1st post in this topic.

Edited by TheXman
Link to post
Share on other sites
1 hour ago, qinylj said:

There is an exception in the _Json_token function that is not judged, if the key value is an empty array, there will be a problem。Corrected as follows:

case 2;Json_ARRAY
    If $Size = 0 Then
      Local $Array = null
    Else
        Origin Code Here
   Endif

 

Please show complete reproducer.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

Link to post
Share on other sites

Hello, thanks for your answers.
I'll try the UDFs you provided and let me know how it goes, though we'll most likely have to rewrite parts of a JSON-based UDF.
About JSMN, the danger and the code injection, the truth would be needing a little more context...

Quote

JSMN, which is the JSON parsing engine that the json.au3 UDF lib is built around, is one of the fastest parsing engines around.  So I seriously doubt that any performance issues with your script are related to the functions in the UDF lib.  The most likely cause of your performance issues is the logic you are using to get the data or information that you want from the JSON.  As you've read, there are multiple tools & UDF's available for parsing (and processing) JSON.  If you are primarily wanting to pluck (parse) out data values, then I'm sure that the json.au3 UDF can do it as fast and efficiently as most any other JSON parsing engine.  If you need to gather more than just data, meaning you need to gather information (like sums, averages, counts/stats, etc.), add/delete/modify JSON values or objects, or reformat/splice/extract JSON structures, then I would suggest a tool like jq.  Some might even suggest parsing JSON using regular expressions, which may be very fast but (in my opinion) not as reliable, unless you have full control over the JSON being used as input (the order of the JSON data AND and its formatting).

Well, I'll explain and I'm sorry in advance if I didn't make myself understood. Yes, that is what I meant. This UDF uses JSON.au3, and the contents of the JSON that take time to process are arrays that contain information, and what we do is extract that data from the JSON array to convert it into an array for the UDF to manipulate and examine it.

 

Link to post
Share on other sites

Well, in case more is needed, a sample of this is a UDF that I have been making in the company of @Danyfirex. Especially, in the FakeYou.au3 UDF, functions _FakeYouGetVoicesList and _FakeYouGetCategoriesList (in the latter it is acceptable but in the previous function it takes time to process the data) This is the GitHub: UDF repository

BTW, I'm sorry for my english... :(

Link to post
Share on other sites
Posted (edited)

@Mateocedillo

I took a quick look at your _FakeYouGetVoicesList() function.  I'm not sure how long your functions takes on your test PC's but, I have written a function that creates the voices array in a little over half a second on my PC. My array includes all of the values in each model, just like your function.

Output:

Time to create array: 0.518 seconds
Number of rows:       1941
Number of cols:       15

My script uses jq to create the array because I think it is better suited for this particular task.  Since I think discussing alternative solutions in detail, in someone else's topic is rude, I will not go into detail on how I did it here.  If you want to see suggestions on how it could be done using jq, then I would suggest that you create a new topic with any questions that you may have related to using jq.

If you want to stick with the json.au3 UDF, then there are several ways to speed up your function.  Since none of these suggestions have anything to do with the json.au3 UDF itself, and the fact that your issues have nothing to do with the json.au3 functionality, I'm not sure that this is the right topic for a detailed discussion on how it could be done.  So without going into detail, I will just list a few items/questions for you to think about in  terms of speeding up that function:

  1. Do you really need an array at all?  Basically you are moving all of the data from one structured format (json/dictionary) that can be queried to another one (variant array), that seems totally unnecessary and time-consuming.
  2. Do you really need to have all of those values in your array?  If you don't need or use values like create_at/update_at/etc, why take the time to move them to a separate array?
  3. Working with arrays and strings are 2 of the slowest processes you can do in AutoIt.  The fewer execution of array and string functions you need to create your array, the faster that process will be.
Edited by TheXman
Link to post
Share on other sites
1 hour ago, TheXman said:

@Mateocedillo

I took a quick look at your _FakeYouGetVoicesList() function.  I'm not sure how long your functions takes on your test PC's but, I have written a function that creates the voices array in a little over have a second on my PC. My array includes all of the values in each model, just like your function.

Output:

Time to create array: 0.518 seconds
Number of rows:       1941
Number of cols:       15

My script uses jq to create the array because I think it is better suited for this particular task.  Since I think discussing alternative solutions in detail, in someone else's topic is rude, I will not go into detail on how I did it here.  If you want to see suggestions on how it could be done using jq, then I would suggest that you create a new topic with any questions that you may have related to using jq.

If you want to stick with the json.au3 UDF, then there are several ways to speed up your function.  Since none of these suggestions have anything to do with the json.au3 UDF itself, and the fact that your issues have nothing to do with the json.au3 functionality, I'm not sure that this is the right topic for a detailed discussion on how it could be done.  So without going into detail, I will just list a few items/questions for you to think about in  terms of speeding up that function:

  1. Do you really need an array at all?  Basically you are moving all of the data from one structured format (json/dictionary) that can be queried to another one (variant array), that seems totally unnecessary and time-consuming.
  2. Do you really need to have all of those values in your array?  If you don't need or use values like create_at/update_at/etc, why take the time to move them to a separate array?
  3. Working with arrays and strings are 2 of the slowest processes you can do in AutoIt.  The fewer execution of array and string functions you need to create your array, the faster that process will be.

I understand. Well, anyway feel free to send pull requests and so on, although I know I have to do my part and I take it into account. It takes me about 20-30 seconds to finish. And yes, I think the last items (created at and updated at) may not be necessary for now, so I'll think about doing something to speed up the process, as well as alternatives. Thank you anyway...

Link to post
Share on other sites
Posted (edited)
On 7/4/2022 at 11:32 AM, Mateocedillo said:

Well, anyway feel free to send pull requests...Thank you anyway...

Unfortunately, without a compelling reason, I have no intention of doing any pull requests or otherwise doing any of your scripting for you.  You're welcome anyway... 

If you are interested in learning more about jq and how to use it, I may be willing to help you with that.

 

On 7/4/2022 at 11:32 AM, Mateocedillo said:

It takes me about 20-30 seconds to finish

If it takes your script 20-30 seconds to build your array using json.au3 functions and it only takes 0.5 seconds to build the same array using jq, then it might be worth taking the time to learn how to use jq.  JSMN (json.au3) is a great JSON parser.  jq is a great JSON processor

Generating a tab-separated-value list of all of the data needed to build the array is done in a single function call to jq, which returns its result in well under 0.5 seconds (it took an additional 0.1 seconds to convert the TSV list to an array which came to a total elapsed time of just over 0.5 seconds).  Your current way is to loop through the 1900+ array objects, with each object containing 15 key/value pairs, doing over 29,000 json_get() calls in order to parse and put each individual value into your array.  I think it is pretty clear why your way takes considerably longer (20-30 seconds) to generate its result.

This was an excellent example of the difference between JSON parsing and JSON processing.  It was also an excellent example of how using the right tool(s) for the job can make a HUGE difference!

Edited by TheXman
Link to post
Share on other sites
  • 2 months later...


Ok, so sorry if this is covered or if I do not include all the correct information, I'm no seasoned programmer just trying to learn what I need to get by. 

I have managed to learn over the last few weeks how to decompile a msgpack string into json and then use this UDF to get/put data and recompile back to msgpack. 

I am stuck on what seems a simple problem that no suggestions in this thread have worked and I see this has been noted as an issue but the latest UDF is not allowing me to progress. I am using the UDF by Ward, 2021.11.20

The issue is when a period is within the key itself so I have this sample json here I am trying to read the VST.magic and VST3.uid values: 
 

{
  "VST.magic","Test"
  "VST3.uid",[
    2229853791
    2455052834
    2533024787
    1016289816
  ]
  "pluginName","Omnisphere"
  "pluginVendor","Spectrasonics"
}

I have this example code: 

$sJsonString =  FileRead(@ScriptDir & "\Test_PLID_Data.json")
Json_Dump($sJsonString)
$oJsonString = Json_Decode($sJsonString)
;$aKey = $oJsonString.keys

$data = Json_Get($oJsonString, '.VST.magic')
ConsoleWrite("RESULT = " & $data & @CRLF)

I cannot get any result  trying to read these keys, just blank.

This works fine: 
$data = Json_Get($oJsonString, '.pluginName')

And the above will work if I remove the period from the key and try read it again so it is specific to the period in the key.

I saw this as an issue some time ago and some workaround proposed do not work for me. I have tried: 

$data = Json_Get($oJsonString, '."VST"."magic"')

$data = Json_Get($oJsonString, '.VST."magic"')

$data = Json_Get($oJsonString, '[VST][magic]')

$data = Json_Get($oJsonString, '[VST]["magic"]')

And probably every variation of all the above attempts but cannot get anything to work. 

EDIT: My current method to work around this since these are the only 2 keys that have a period is to StringReplace these with _ to allow my code to do what needs to be done then substitute the period back again when writing the string out again. Not perfect but works.

Edited by jestermgee
Link to post
Share on other sites
On 9/19/2022 at 5:35 AM, jestermgee said:


Ok, so sorry if this is covered or if I do not include all the correct information, I'm no seasoned programmer just trying to learn what I need to get by. 

I have managed to learn over the last few weeks how to decompile a msgpack string into json and then use this UDF to get/put data and recompile back to msgpack. 

I am stuck on what seems a simple problem that no suggestions in this thread have worked and I see this has been noted as an issue but the latest UDF is not allowing me to progress. I am using the UDF by Ward, 2021.11.20

The issue is when a period is within the key itself so I have this sample json here I am trying to read the VST.magic and VST3.uid values: 
 




{
  "VST.magic","Test"
  "VST3.uid",[
    2229853791
    2455052834
    2533024787
    1016289816
  ]
  "pluginName","Omnisphere"
  "pluginVendor","Spectrasonics"
}

I have this example code: 

$sJsonString =  FileRead(@ScriptDir & "\Test_PLID_Data.json")
Json_Dump($sJsonString)
$oJsonString = Json_Decode($sJsonString)
;$aKey = $oJsonString.keys

$data = Json_Get($oJsonString, '.VST.magic')
ConsoleWrite("RESULT = " & $data & @CRLF)

I cannot get any result  trying to read these keys, just blank.

This works fine: 
$data = Json_Get($oJsonString, '.pluginName')

And the above will work if I remove the period from the key and try read it again so it is specific to the period in the key.

I saw this as an issue some time ago and some workaround proposed do not work for me. I have tried: 

$data = Json_Get($oJsonString, '."VST"."magic"')

$data = Json_Get($oJsonString, '.VST."magic"')

$data = Json_Get($oJsonString, '[VST][magic]')

$data = Json_Get($oJsonString, '[VST]["magic"]')

And probably every variation of all the above attempts but cannot get anything to work. 

EDIT: My current method to work around this since these are the only 2 keys that have a period is to StringReplace these with _ to allow my code to do what needs to be done then substitute the period back again when writing the string out again. Not perfect but works.

 

 

You might want to try something like this:
 

$sJsonString =  FileRead(@ScriptDir & "\Test_PLID_Data.json")
$JsonObj = Json_Decode($sJsonString)

If Json_IsObject($JsonObj) Then
    Local $Keys = Json_ObjGetKeys($JsonObj)
    Local $Index = _ArraySearch($Keys,"VST.Magic")
    Local $data[1] = [$JsonObj.Items[$Index]]
    ConsoleWrite("RESULT1 = " & $data[0] & @CRLF)
EndIf

Also you can get direct array results from the object like this:
If $JsonObj.Keys[0]=='VST.Magic' Then.....
If $JsonObj.Items[0]=='Test' Then.....

See also:
https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/items-method

The UDF can only do so much things, in some cases you will have to supply your own routines to handle the objects.

 

 

Edited by lbsl
Link to post
Share on other sites

In case anyone desires to have the dump-function output to a 2D array rather than a string, replace the _json_tokenDump with this one:

Func _Json_TokenDump(ByRef $Json, $Ptr, ByRef $Next, $ObjPath = "")
    If $Next = -1 Then Return Null

    Local $Token = DllStructCreate("int;int;int;int", $Ptr + ($Next * 20))
    Local $Type = DllStructGetData($Token, 1)
    Local $Start = DllStructGetData($Token, 2)
    Local $End = DllStructGetData($Token, 3)
    Local $Size = DllStructGetData($Token, 4)
    Local $Value
    $Next += 1

    If $Type = 0 And $Start = 0 And $End = 0 And $Size = 0 Then ; Null Item
        $Next = -1
        Return Null
    EndIf

    Switch $Type
        Case 0 ; Json_PRIMITIVE
            Local $Primitive = StringMid($Json, $Start + 1, $End - $Start)
            Switch $Primitive
                Case "true"
                    Return "True"
                Case "false"
                    Return "False"
                Case "null"
                    Return "Null"
                Case Else
                    If StringRegExp($Primitive, "^[+\-0-9]") Then
                        Return Number($Primitive)
                    Else
                        Return Json_StringDecode($Primitive)
                    EndIf
            EndSwitch

        Case 1 ; Json_OBJECT
            For $i = 0 To $Size - 1 Step 2
                Local $Key = _Json_TokenDump($Json, $Ptr, $Next)
                Local $cObjPath = $ObjPath & "." & $Key
                $Value = _Json_TokenDump($Json, $Ptr, $Next, $ObjPath & "." & $Key)
                If Not (IsBool($Value) And $Value = False) Then
                    If Not IsString($Key) Then
                        $Key = Json_Encode($Key)
                    EndIf
                    If Not IsArray($Total_JSON_DUMP_Output) Then
                        Dim $Total_JSON_DUMP_Output[1][2]
                    Else
                        ReDim $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) + 1][2]
                    EndIf                    ; show the key and its value
                    ConsoleWrite("+-> " & $cObjPath & '  =' & $Value & @CRLF)
                    $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) - 1][0] = $cObjPath
                    $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) - 1][1] = $Value
                    ;$Total_JSON_DUMP_Output &= "+-> " & $cObjPath & '  =' & $Value & @CRLF
                EndIf
            Next
            Return False
        Case 2 ; Json_ARRAY
            Local $sObjPath = $ObjPath
            For $i = 0 To $Size - 1
                $sObjPath = $ObjPath & "[" & $i & "]"
                $Value = _Json_TokenDump($Json, $Ptr, $Next, $sObjPath)
                If Not (IsBool($Value) And $Value = False) Then ;XC - Changed line
                    ; show the key and its value
                    If Not IsArray($Total_JSON_DUMP_Output) Then
                        Dim $Total_JSON_DUMP_Output[1][2]
                    Else
                        ReDim $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) + 1][2]
                    EndIf
                    ConsoleWrite("+=> " & $sObjPath & "=>" & $Value & @CRLF)
                    $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) - 1][0] = $sObjPath
                    $Total_JSON_DUMP_Output[UBound($Total_JSON_DUMP_Output) - 1][1] = $Value
                    ;$Total_JSON_DUMP_Output &= "+=> " & $sObjPath & "=>" & $Value & @CRLF
                EndIf
            Next
            $ObjPath = $sObjPath
            Return False

        Case 3 ; Json_STRING
            Local $LastKey = Json_StringDecode(StringMid($Json, $Start + 1, $End - $Start))
            Return $LastKey
    EndSwitch
EndFunc   ;==>_Json_TokenDump

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rot3r
      Hi friends,
      I'm using json.au3 to register some data in my server, everything work fine except the data that i send in utf8 format like names saved as ????? .
      i think something mess with inetget cause this problem
      can you help me please?
      $sAdditionalData = "secret_key=" & $secret_key_verify & "&slm_action=slm_check&license_key=" & $license_key&"&first_name="&$first_name $data = _INetGetSource($sDomain&'/?'&$sAdditionalData) $object = json_decode($data) Json_Dump($data) $response = json_get($object, '.first_name')  
    • By TheXman
      This UDF brings the power and flexibility of jq to AutoIt scripts.  jq is an open-source, powerful, and flexible command-line based JSON processor.  As it says on their website, jq is like 'sed' for JSON.  jq can be used for the simplest of tasks like retrieving JSON objects and values (parsing), to very advanced JSON processing using its numerous built-in functions and conditional processing.  Its built-in functions can handle math, selection, conditional processing, mapping, object and array manipulation, flattening, reduction, grouping, and much more.  You can even create your own jq functions.  You can learn more about jq and even play with it in real-time, using jq's online jq playground, all on their website.
      Here and some helpful links to get you more familiar with jq, what can be done with it, its built-in functions, and its syntax.
      jq Website: https://stedolan.github.io/jq/ jq Manual: https://stedolan.github.io/jq/manual/ jqWiki (FAQ, Cookbook, Advanced Topics) https://github.com/stedolan/jq/wiki jq Online Testing Playground: https://jqplay.org/ jq is a single 32 or 64 bit executable that has no other dependencies.  Just like using the SQLite UDF, the only requirement to use this UDF is that the jq executable reside in a location in which the UDF can execute it.  The latest win32 & win64 versions have been included in the UDF download.  You can always get newer versions from the jq website.
      I don't consider this UDF as a replacement for some of the other JSON UDFs like the one based on JSMN.  If speed and simple JSON parsing are your primary goals, then other UDFs may be a better choice.  However, if you like having the power to do just about anything related to JSON processing/manipulation, using a single UDF, then jq may be worth checking out.  It can be used by novices and experts alike.  Below, is a brief explanation of how jq works, how to use the jq UDF, and a few examples of how to do some simple tasks.  If you want to learn more about jq and what it can do, I would highly suggest checking out the jq website and some of the other resources listed above.
      jq at a high level
      Like 'sed', jq reads JSON in, either through STDIN or one or more files, processes it thru one or more "filters", and outputs the results.  You can, optionally, supply "options" that affect how it reads the input, where it gets its "filters", and how it writes its output.  It looks a little like this:
      JSON ---> jq processor (using supplied filters and options) ---> Output
      So in jq lingo, you basically use "Filters" to tell jq what you want it to do.  So in the UDF file, that is why the main functions ( _jqExec() and _jqExecFile() ) refer to filters and options.  Please make note that jq works with relatively strict JSON.  This means that all JSON read must be conform to the standard.  Luckily, jq is pretty good at identifying where a format error exists in non standard JSON.
      The jq UDF
      There are 2 main funtions in the UDF file, _jqExec and jqExecFile.  With these 2 functions, you can pretty much do anything that jq can do.  The only difference between to two functions is whether the JSON is supplied by a string or a file.  The 2 primary functions simply call the jq executable with the supplied information, after properly formatting the parameters.  There are additional functions in the UDF to easily pretty-print your json, compact-print your json, dump the json data with its associated paths, and see if specific JSON keys exist, but they all just execute the _jqExec or _jqExecFile function with the proper filter.  There are also a couple of extra functions to display what version of the UDF and jq executable you are currently using.  There are also a couple of functions to enable and disable logging of jq information for debugging purposes.  Most of the jq UDF file functions return an @error if unsuccessful.  Some also include @extended info.  Please see the actual function headers for more information on their usage and return values.
      The 2 primary functions below just format your jq request and pass it on the jq executable.  The functions will also properly escape double quotes (") that are used in the filter.  For most simple tasks, you just need to supply the JSON source and a filter.
      _jqExec($sJson, $sFilter, $sOptions = Default, $sWorkingDir = Default) Or _jqExecFile($sJsonFile, $sFilter, $sOptions = Default, $sWorkingDir = Default) Using jq in your script
      As stated earlier, the jq executable must reside somewhere where the script can locate and execute it.  The _jqInit() function always has to be executed before any jq processing occurs.  _jqInit() merely locates the executable or uses the supplied path.  It also clears any previous debug log.  The jq UDF folder contains a jq example script that has several examples to how to do some of the most common JSON processing tasks.  Here are a few examples to get you started:

      How to pretty-print some JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"fruits":[{"Apple":{"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sCmdOutput & @CRLF) How to compact-print some JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sCmdOutput & @CRLF) Dump JSON data (paths and values)
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqDump($sJson) ConsoleWrite(@CRLF & "Dump JSON paths and values" & @CRLF & $sCmdOutput & @CRLF) How to GET JSON values
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana.color' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) or
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'getpath(["Banana", "color"])' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF)  
      Check for the existence of a key
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | has("color")' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Check for existence of color key within Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Count of how many Items in an object
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | length' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("How many items in the Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) How to PUT/Create/Modify JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sInput = "" $sFilter = 'setpath(["Apple","color"];"Red") | setpath(["Banana","color"];"Yellow") | setpath(["Banana","season"];"Summer")' $sOptions = '-n' ;required if no input supplied $sCmdOutput = _jqExec($sInput, $sFilter, $sOptions) ConsoleWrite("Update/Create JSON" & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) List all of the fruits (top-level keys)
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'keys | .[]' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("List all top-level keys (fruits)" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) Calculate the sum of all of the objects' price * qty
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '[{"id":1,"price":20.00,"qty":10},{"id":2,"price":15.00,"qty":20.25},{"id":3,"price":10.50,"qty":30}]' $sFilter = 'map(.price * .qty) | add' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Calculate the sum of all of the objects' price * qty" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF)
      The examples above, and the ones in the example files, merely scratch the surface of what jq can do.  It may look intimidating at first but it really isn't that bad once you start playing with it.
      If you have any questions regarding the UDF, or how to perform a certain task using jq, I'll try my best to answer them.  Since jq has been around for a while now, there's also several jq-related questions and answers on StackOverflow.
      If you work with JSON, I hope you find this UDF useful as I do.
      >>> Download in the Files Section <<<
       
    • By TheXman
      This UDF brings the power and flexibility of jq to AutoIt scripts.  jq is an open-source, powerful, and flexible command-line based JSON processor.  As it says on their website, jq is like 'sed' for JSON.  jq can be used for the simplest of tasks like retrieving JSON objects and values (parsing), to very advanced JSON processing using its numerous built-in functions and conditional processing.  Its built-in functions can handle math, selection, conditional processing, mapping, object and array manipulation, flattening, reduction, grouping, and much more.  You can even create your own jq functions.  You can learn more about jq and even play with it in real-time, using jq's online jq playground, all on their website.
      Here and some helpful links to get you more familiar with jq, what can be done with it, its built-in functions, and its syntax.
      jq Website: https://stedolan.github.io/jq/ jq Manual: https://stedolan.github.io/jq/manual/ jqWiki (FAQ, Cookbook, Advanced Topics) https://github.com/stedolan/jq/wiki jq Online Testing Playground: https://jqplay.org/ jq is a single 32 or 64 bit executable that has no other dependencies.  Just like using the SQLite UDF, the only requirement to use this UDF is that the jq executable reside in a location in which the UDF can execute it.  The latest win32 & win64 versions have been included in the UDF download.  You can always get newer versions from the jq website.
      I don't consider this UDF as a replacement for some of the other JSON UDFs like the one based on JSMN.  If speed and simple JSON parsing are your primary goals, then other UDFs may be a better choice.  However, if you like having the power to do just about anything related to JSON processing/manipulation, using a single UDF, then jq may be worth checking out.  It can be used by novices and experts alike.  Below, is a brief explanation of how jq works, how to use the jq UDF, and a few examples of how to do some simple tasks.  If you want to learn more about jq and what it can do, I would highly suggest checking out the jq website and some of the other resources listed above.
      jq at a high level
      Like 'sed', jq reads JSON in, either through STDIN or one or more files, processes it thru one or more "filters", and outputs the results.  You can, optionally, supply "options" that affect how it reads the input, where it gets its "filters", and how it writes its output.  It looks a little like this:
      JSON ---> jq processor (using supplied filters and options) ---> Output
      So in jq lingo, you basically use "Filters" to tell jq what you want it to do.  So in the UDF file, that is why the main functions ( _jqExec() and _jqExecFile() ) refer to filters and options.  Please make note that jq works with relatively strict JSON.  This means that all JSON read must be conform to the standard.  Luckily, jq is pretty good at identifying where a format error exists in non standard JSON.
      The jq UDF
      There are 2 main funtions in the UDF file, _jqExec and jqExecFile.  With these 2 functions, you can pretty much do anything that jq can do.  The only difference between to two functions is whether the JSON is supplied by a string or a file.  The 2 primary functions simply call the jq executable with the supplied information, after properly formatting the parameters.  There are additional functions in the UDF to easily pretty-print your json, compact-print your json, dump the json data with its associated paths, and see if specific JSON keys exist, but they all just execute the _jqExec or _jqExecFile function with the proper filter.  There are also a couple of extra functions to display what version of the UDF and jq executable you are currently using.  There are also a couple of functions to enable and disable logging of jq information for debugging purposes.  Most of the jq UDF file functions return an @error if unsuccessful.  Some also include @extended info.  Please see the actual function headers for more information on their usage and return values.
      The 2 primary functions below just format your jq request and pass it on the jq executable.  The functions will also properly escape double quotes (") that are used in the filter.  For most simple tasks, you just need to supply the JSON source and a filter.
      _jqExec($sJson, $sFilter, $sOptions = Default, $sWorkingDir = Default) Or _jqExecFile($sJsonFile, $sFilter, $sOptions = Default, $sWorkingDir = Default) Using jq in your script
      As stated earlier, the jq executable must reside somewhere where the script can locate and execute it.  The _jqInit() function always has to be executed before any jq processing occurs.  _jqInit() merely locates the executable or uses the supplied path.  It also clears any previous debug log.  The jq UDF folder contains a jq example script that has several examples to how to do some of the most common JSON processing tasks.  Here are a few examples to get you started:

      How to pretty-print some JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"fruits":[{"Apple":{"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sCmdOutput & @CRLF) How to compact-print some JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sCmdOutput & @CRLF) Dump JSON data (paths and values)
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqDump($sJson) ConsoleWrite(@CRLF & "Dump JSON paths and values" & @CRLF & $sCmdOutput & @CRLF) How to GET JSON values
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana.color' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) or
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'getpath(["Banana", "color"])' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF)  
      Check for the existence of a key
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | has("color")' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Check for existence of color key within Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Count of how many Items in an object
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | length' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("How many items in the Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) How to PUT/Create/Modify JSON
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sInput = "" $sFilter = 'setpath(["Apple","color"];"Red") | setpath(["Banana","color"];"Yellow") | setpath(["Banana","season"];"Summer")' $sOptions = '-n' ;required if no input supplied $sCmdOutput = _jqExec($sInput, $sFilter, $sOptions) ConsoleWrite("Update/Create JSON" & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) List all of the fruits (top-level keys)
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'keys | .[]' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("List all top-level keys (fruits)" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) Calculate the sum of all of the objects' price * qty
      #include "jq.au3" _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '[{"id":1,"price":20.00,"qty":10},{"id":2,"price":15.00,"qty":20.25},{"id":3,"price":10.50,"qty":30}]' $sFilter = 'map(.price * .qty) | add' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Calculate the sum of all of the objects' price * qty" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF)
      The examples above, and the ones in the example files, merely scratch the surface of what jq can do.  It may look intimidating at first but it really isn't that bad once you start playing with it.
      If you have any questions regarding the UDF, or how to perform a certain task using jq, I'll try my best to answer them.  Since jq has been around for a while now, there's also several jq-related questions and answers on StackOverflow.
      If you work with JSON, I hope you find this UDF useful as I do.
    • By argumentum
      #include <SQLite.au3> ;-- When SQLite is compiled with the JSON1 extensions it provides builtin tools ;-- for manipulating JSON data stored in the database. ;-- This is a gist showing SQLite return query as a JSON object. ;-- https://www.sqlite.org/json1.html Example() Func Example() _SQLite_Startup() ; "<your path>\sqlite3.dll", False, 1) ; https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm _SQLite_Open() ; ...if you can not run this due to errors, get the latest DLL from https://www.sqlite.org/ If _SQLite_Exec(-1, "CREATE TABLE users (id INTEGER PRIMARY KEY NOT NULL, full_name TEXT NOT NULL, email TEXT NOT NULL, created DATE NOT NULL );") Then Return 4 If _SQLite_Exec(-1, 'INSERT INTO users VALUES ' & _ '(1, "Bob McFett", "bmcfett@hunters.com", "32-01-01"),' & _ '(2, "Angus O''Vader","angus.o@destroyers.com", "02-03-04"),' & _ '(3, "Imperator Colin", "c@c.c", "01-01-01");') Then Return 5 ; -- Get query data as a JSON object using the ; -- json_group_object() [1] and json_object() [2] functions. _SQLite_GetTable2d_ArrayToConsole("SELECT" & _ " json_group_object(" & _ " email," & _ " json_object('full_name', full_name, 'created', created)" & _ " ) AS json_result" & _ " FROM (SELECT * FROM users WHERE created > ""02-01-01"");") ; {"bmcfett@hunters.com":{"full_name":"Bob McFett","created":"32-01-01"},"angus.o@destroyers.com":{"full_name":"Angus O'Vader","created":"02-03-04"}} ; -- Get query data as a JSON object using the ; -- json_group_array() function to maintain order. _SQLite_GetTable2d_ArrayToConsole("SELECT" & _ " json_group_array(" & _ " json_object('full_name', full_name, 'created', created)" & _ " ) AS my_json_result_OrAnythingReally" & _ " FROM (SELECT * FROM users ORDER BY created);") ; [{"full_name":"Imperator Colin","created":"01-01-01"},{"full_name":"Angus O'Vader","created":"02-03-04"},{"full_name":"Bob McFett","created":"32-01-01"}] ;-- Links ;-- [1] https://www.sqlite.org/json1.html#jgroupobject ;-- [2] https://www.sqlite.org/json1.html#jobj ; example found at https://gist.github.com/akehrer/481a38477dd0518ec0086ac66e38e0e2 EndFunc ;==>Example Func _SQLite_GetTable2d_ArrayToConsole($sSQL, $hDB = -1) Local $aResult, $iRows, $iColumns If _SQLite_GetTable2d($hDB, $sSQL, $aResult, $iRows, $iColumns) Then ConsoleWrite("! SQLite Error: " & _SQLite_ErrCode($hDB) & @CRLF & "! " & _SQLite_ErrMsg($hDB) & @CRLF) Else _SQLite_Display2DResult($aResult) EndIf ConsoleWrite(@CRLF) EndFunc ;==>_SQLite_GetTable2d_ArrayToConsole Based on this example, you can build your own query. 
      The code has all the explanations.
      Enjoy  
    • By matwachich
      Hi AutoIters!
      Here is my new UDF about GUIs: it's an enhanced mixture of Advanced InputBox (deprecated) and KODA Parser (deprecated), with additional functions.
      What you can do with it:
      Parse KODA files and directly create GUIs (_GUIUtils_CreateFromKODA) Parse a simple JSON form definition to simply create advanced InputBoxes with any amount/type of input controls (_GUIUtils_CreateFromJSON) Created GUIs are returned as Scripting.Dictionary objects, and you have helper functions to access GUIs controls by their names (_GUIUtils_HWnd, _GUIUtils_CtrlID, _GUIUtils_HCtrl ...) A function that can make a GUI created from KODA/JSON (defined by it's $oForm object) and make it a modal InputDialogBox (just like InputBox, but returns all entered data as Scripting.Dictionary object) Functions are documented, and there are some examples.
      Consider this UDF as beta, but since I'm currently using it in a small commercial project, it should become production ready in near future.
      To always get the latest code version, get it from Github (more up to date than this topic).
      Update 04/02/2020:
      New simple application example Fixed focused control handling in _GUIUtils_InputDialog Reset input values before returning from _GUIUtils_InputDialog Fixed CloseOnEsc in _GUIUtils_InputDialog Fixed Input not reset Fixed all ListBox items are selected Project now on GitHub https://github.com/matwachich/autoit-guiutils/
      Update 05/02/2020:
      Support for nodate for Date and Time input controls (pass null value) New handling of focused control _GUIUtils_InputDialog: Now, you can specify the focused control in $oInitialData by setting "controlName:focus" = True Updated documentation of _GUIUtils_InputDialog Update 07/02/2020:
      Bug corrected when setting Data input control Added: abillity to read a single input control New functions (_GUIUtils_GetInputs, _GUIUtils_WriteInputs), documentation completion. Readme file and screenshots on Github Page  
      GUIUtils.zip
×
×
  • Create New...