Jump to content

A Non-Strict JSON UDF (JSMN)


Ward
 Share

Recommended Posts

:)

Now you are starting to get into the differences between JSON parsers, like jsmn which this UDF is based on, and JSON processors like jq.  Parsers are great for getting and, sometimes, putting specific pieces of data.  Although JSON processors have the ability to parse data too, they excel when it comes to manipulating JSON, such as in the case of deleting, adding, inserting, splicing, splitting, reformatting, and other functions changing JSON data and its structures as well as gathering information from JSON datasets by summing, averaging, and gathering other types of information from complete JSON datasets.  For most people, parsing is all they need (or think they need).  But for those that really work with JSON datasets, parsers are not powerful enough for most tasks, and that is where processors shine.

I think it would be great to add processor-type functionality to the json.au3 library.  But jsmn was not really designed for processing JSON.  So trying to take the json.au3 library from a great JSON parser to a great JSON processor would be a interesting and fun project.  But it is a whole different ballgame.  😉

Edited by TheXman
Link to comment
Share on other sites

  • 7 months later...

@Jos

The topic below, posted by @zeehteam, identified a slight flaw in the json_get and json_put functions as it relates to handling key names that are provided using a string.  The regular expressions used to identify dot and bracket notations are a little too narrow.  Basically, the current regular expressions do not allow valid key names that have embedded right brakets ("[") in them.  Although such key names are odd and rare, they are valid.

 

The attached json udf has slightly modified versions of json_get() and json_put() for your review.  The only modification to the 2 functions is in how they identify and parse the notations in order to be more fully compliant with the standard.  Basically, it assumes that there are 4 types of notations:

  1. Dot-notation using a literal value (ex.  .name)
  2. Dot-notation using a string value (ex.  ."name")
  3. Bracket-notation using a literal value (ex.  [name])
  4. Bracket-notation using a string value (ex.  ["name"])

Indexes that are passed are correctly handled as bracket-notation using a literal (ex.  [0]).

To make it easier to maintain in the future, the only modifications to the 2 functions are at the very beginning where the notations are identified.  The rest of the logic in json_get and json_put remained the same.

 

The following example and output, using the modified functions, shows that the functions are correctly handling existing functionality and the ability to handle the new functionality.

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

#include <Constants.au3>
#include <MyIncludes\json\json (modified).au3> ;<== change to your location

Const $JSON = _
    '{ ' & _
    '   "project": "Listing droids", ' & _
    '   "version": "1.0", ' & _
    '   "hasErrors": false, ' & _
    '   "author": { ' & _
    '      "name": "Luke", ' & _
    '      "mail": "luke@2080.org" ' & _
    '   }, ' & _
    '   "[[[/script/droids]]]": [ ' & _
    '      { ' & _
    '         "name": "R2D2", ' & _
    '         "type": "Astromecano", ' & _
    '         "size": "0,96m" ' & _
    '      }, ' & _
    '      { ' & _
    '         "name": "BB8", ' & _
    '         "type": "Astromecano", ' & _
    '         "size": "0,67m" ' & _
    '      } ' & _
    '   ] ' & _
    '} '

json_example()

Func json_example()
    Local $oJSON
    Local $Key, $Value

    $oJSON = Json_Decode($JSON)
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Decode error - @error = " & @error)

    ;Get values
    $Key   = '."[[[/script/droids]]]"[0].name'
    $Value = Json_Get($oJSON, $Key)
    ConsoleWrite($Key & "   = " & $Value & @CRLF)

    $Key   = '["[[[/script/droids]]]"][0][name]'
    $Value = Json_Get($oJSON, $Key)
    ConsoleWrite($Key & " = " & $Value & @CRLF)

    $Key   = '.author."name"'
    $Value = Json_Get($oJSON, $Key)
    ConsoleWrite($Key & "   = " & $Value & @CRLF)

    $Key   = '[author]["name"]'
    $Value = Json_Get($oJSON, $Key)
    ConsoleWrite($Key & " = " & $Value & @CRLF)

    ;Put values
    $oJSON = ""
    json_put($oJSON, '.description', "test json dataset")
    json_put($oJSON, '.author', "TheXman")

    json_put($oJSON, '."[[test]]"[0].name', "test name 1")
    json_put($oJSON, '."[[test]]"[0].number', 1)
    json_put($oJSON, '."[[test]]"[0].boolean', True)
    json_put($oJSON, '."[[test]]"[0].null_value', Null)

    json_put($oJSON, '["[[test]]"][1][name]', "test name 2")
    json_put($oJSON, '["[[test]]"][1][number]', 2.5)
    json_put($oJSON, '["[[test]]"][1][boolean]', False)
    json_put($oJSON, '["[[test]]"][1][null_value]', Null)

    ConsoleWrite(@CRLF)
    ConsoleWrite(Json_Encode($oJSON, $JSON_PRETTY_PRINT) & @CRLF)
EndFunc

Output

."[[[/script/droids]]]"[0].name   = R2D2
["[[[/script/droids]]]"][0][name] = R2D2
.author."name"   = Luke
[author]["name"] = Luke

{
    "description": "test json dataset",
    "author": "TheXman",
    "[[test]]": [
        {
            "name": "test name 1",
            "number": 1,
            "boolean": true,
            "null_value": null
        },
        {
            "name": "test name 2",
            "number": 2.5,
            "boolean": false,
            "null_value": null
        }
    ]
}

 

Json (modified).au3

Edited by TheXman
Fixed typos
Link to comment
Share on other sites

  • Developers
2 hours ago, TheXman said:

The attached json udf has slightly modified versions of json_get() and json_put() for your review.

I assume you tested it and all is working so just updated the first post in the thread with your update. :)  

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 comment
Share on other sites

Yes, I tested it using the test script that comes bundled with the UDF's zip file as well as several of my own tests.

Thanks Jos!  :)

Edited by TheXman
Link to comment
Share on other sites

Give me few hours.
I will test with my WD related projects.

Edited by mLipok

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

4 hours ago, mLipok said:

Give me few hours.
I will test with my WD related projects.

Works well on 2 advanced WD automation also with my capabilities UDF.

 

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

Link to comment
Share on other sites

For anyone who may need it and in response to the above post, I have attached a modified version of the latest UDF that adds 3 new "helper" functions:

  1. Json_ArrayAdd(ByRef $Var, $Notation, $Data)
    Adds an item (String, number, object, array, or boolean) to an existing array.
  2. Json_ArrayInsert(ByRef $Var, $Notation, $Index, $Data)
    Inserts an array item (String, number, object, array, or boolean) at the specified index.
  3. Json_ArrayDelete(ByRef $Var, $Notation, $Range)
    Deletes a single item, a range of items, or multiple items, from an existing array.  The syntax for $Range is the same as _ArrayDelete() since that is what it uses to delete array items.

Note:  Json_ArrayAdd() and Json_ArrayInsert() only allow adding or inserting a single array item (String, number, object, array, or boolean) at a time.

Below are some examples using the functions and the output that's generated

Spoiler
#include <Constants.au3>
#include <Array.au3>

#include "Json(with array funcs).au3"

Const $JSON = _
    '{' & _
    '   "description": "Test JSON Dataset",' & _
    '   "author": "TheXman",' & _
    '   "obj_array": [' & _
    '      {"name": "Ben Dover", "email": "bdover@example.com"}' & _
    '   ],' & _
    '   "numeric_array": [1,2,3]' & _
    '}'

example()

Func example()
    Local $oJSON = Null, $o
    Local $sKey = ""
    Local $a[0]

    $oJSON = Json_Decode($JSON)
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Unable to decode JSON")

    ;Display current JSON
    ConsoleWrite("Original JSON" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Add objects to the obj_array
    Json_Put($o, '[0].name' , "Eileen Dover")
    Json_Put($o, '[0].email', "email", "edover@example.com")
    Json_ArrayAdd($oJSON, ".obj_array", $o)

    Json_ArrayAdd($oJSON, ".obj_array", Json_Decode('{"name": "John Doe", "email": "jdoe@example.com"}'))
    
    ConsoleWrite(@CRLF & "2 objects added to obj_array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Delete obj_array index 1
    Json_ArrayDelete($oJSON, ".obj_array", 1)
    ConsoleWrite(@CRLF & "Deleted index 1 from obj_array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Insert obj_array index 0
    Json_ArrayInsert($oJSON, ".obj_array", 0, Json_Decode('{"name": "John Smith", "email": "jsmith@example.com"}'))
    ConsoleWrite(@CRLF & "Inserted index 0 into obj_array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Add numbers to the numeric_array
    Json_ArrayAdd($oJSON, ".numeric_array", 4)
    Json_ArrayAdd($oJSON, ".numeric_array", 5)
    Json_ArrayAdd($oJSON, ".numeric_array", 6)
    ConsoleWrite(@CRLF & "Added 4, 5, 6 to numeric array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Delete indexes 3-5 from numeric array
    Json_ArrayDelete($oJSON, ".numeric_array", "3-5")
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Json_ArrayDelete failed - @error = " & @error)
    ConsoleWrite(@CRLF & "Deleted indexes 3-5 from numeric array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)

    ;Insert 4,5,6 at the beginning of numeric_array
    Json_ArrayInsert($oJSON, ".numeric_array", 0, 4)
    Json_ArrayInsert($oJSON, ".numeric_array", 1, 5)
    Json_ArrayInsert($oJSON, ".numeric_array", 2, 6)
    ConsoleWrite(@CRLF & "Inserted 4,5,6 at the beginning of numeric_array" & @CRLF)
    ConsoleWrite(@CRLF & Json_Encode($oJSON, $JSON_PRETTY_PRINT, "   ") & @CRLF)
EndFunc

 

Output:

Spoiler
Original JSON

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "obj_array": [
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      }
   ],
   "numeric_array": [
      1,
      2,
      3
   ]
}

2 objects added to obj_array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "numeric_array": [
      1,
      2,
      3
   ],
   "obj_array": [
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "Eileen Dover",
         "email": "edover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ]
}

Deleted index 1 from obj_array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "numeric_array": [
      1,
      2,
      3
   ],
   "obj_array": [
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ]
}

Inserted index 0 into obj_array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "numeric_array": [
      1,
      2,
      3
   ],
   "obj_array": [
      {
         "name": "John Smith",
         "email": "jsmith@example.com"
      },
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ]
}

Added 4, 5, 6 to numeric array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "obj_array": [
      {
         "name": "John Smith",
         "email": "jsmith@example.com"
      },
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ],
   "numeric_array": [
      1,
      2,
      3,
      4,
      5,
      6
   ]
}

Deleted indexes 3-5 from numeric array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "obj_array": [
      {
         "name": "John Smith",
         "email": "jsmith@example.com"
      },
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ],
   "numeric_array": [
      1,
      2,
      3
   ]
}

Inserted 4,5,6 at the beginning of numeric_array

{
   "description": "Test JSON Dataset",
   "author": "TheXman",
   "obj_array": [
      {
         "name": "John Smith",
         "email": "jsmith@example.com"
      },
      {
         "name": "Ben Dover",
         "email": "bdover@example.com"
      },
      {
         "name": "John Doe",
         "email": "jdoe@example.com"
      }
   ],
   "numeric_array": [
      4,
      5,
      6,
      1,
      2,
      3
   ]
}

 

 

Json(with array funcs).au3

Edited by TheXman
Link to comment
Share on other sites

  • 2 months later...

Please consider to add somehing like $__JSONVERSION and $__BinaryCall_VERSION then other UDF (for example WebDriver UDF) can check if they are recent and put the version to console on debuging runs.


This feature could prevent such issues:

https://github.com/Danp2/WebDriver/pull/173#issuecomment-1029042637

Edited by mLipok

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

  • 1 month later...

I have a problem with Json_ObjGetCount()

Here is my code:

#include "Json.au3"

test5()

Func test5()
    Local $_WD_CAPS__OBJECT
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][0]", 'www.google.com')
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][1]", 'www.yahoo.com')
    ConsoleWrite("Test #5 Result: " & Json_Encode($_WD_CAPS__OBJECT) & @LF)

    Local $oTemp

    $oTemp = Json_ObjGet($_WD_CAPS__OBJECT, 'capabilities.firstMatch[0]')
    ConsoleWrite("! " & @CRLF)

    ConsoleWrite("- " & Json_ObjGetCount($oTemp) & @CRLF)

    Local $noProxy = Json_ObjGet($_WD_CAPS__OBJECT, '[capabilities][firstMatch][0][proxy][noProxy]')
    ConsoleWrite("- " & Json_ObjGetCount($noProxy) & @CRLF)


EndFunc   ;==>test5

 

My question is:  How to get number of [noProxy] entries ?

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

uff.. 
Found this:
 

Local $noProxy = Json_Get($_WD_CAPS__OBJECT, '[capabilities][firstMatch][0][proxy][noProxy]')
    ConsoleWrite("! $noProxy = " & VarGetType($noProxy) & @CRLF)
    ConsoleWrite(UBound($noProxy) & @CRLF)

 

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

Why?

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

Yes. But for my needs it is not necesary as I check it with UBound()
 

#include "Json.au3"

ConsoleWrite('> #' & test5() & @CRLF)

Func test5()
    Local $_WD_CAPS__OBJECT
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][0]", 'www.google.com')
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][1]", 'www.yahoo.com')
    ConsoleWrite("Test #5 Result: " & Json_Encode($_WD_CAPS__OBJECT) & @LF)
    Return UBound(Json_Get($_WD_CAPS__OBJECT, '[capabilities][firstMatch][0][proxy][noProxy]'))
EndFunc   ;==>test5

 

Edited by mLipok

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

On 11/20/2021 at 9:32 PM, TheXman said:

For anyone who may need it and in response to the above post, I have attached a modified version of the latest UDF that adds 3 new "helper" functions:

Hi

Saw today that there is an update on this UDF, thanks TheXman. :)

Tested with my mod manager, no problems found. 

 

Edited by LukeWCS
Link to comment
Share on other sites

Sorry, I dont understand very well english, I am trying to use webdriver to automate Chrome, I download webdriver but I am keep receveing an error like "#include json.udf" I think it's due to lack of this library, but I cannot find where to get it, Can someone help me? Once I downloaded it I should insert it in the include directory in the autoit directory right?

Link to comment
Share on other sites

1 hour ago, MarcoMonte said:

but I am keep receveing an error like "#include json.udf"

The include statement should look like this :

#include "Json.au3"

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • 2 weeks later...

Does the Json_ObjExists() function should support brace-based notation?

I had some problem with this:

#include "Json.au3"

test5()

Func test5()
    Local $_WD_CAPS__OBJECT
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][alwaysMatch]", '{}')
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][0]", 'www.google.com')
    Json_Put($_WD_CAPS__OBJECT, "[capabilities][firstMatch][0][proxy][noProxy][1]", 'www.yahoo.com')
    ConsoleWrite("Test #5 Result: " & Json_Encode($_WD_CAPS__OBJECT) & @LF)
    Local $v_Test

    $v_Test = Json_ObjExists($_WD_CAPS__OBJECT, '[capabilities][firstMatch]')
    ConsoleWrite("- " & @ScriptLineNumber &  ' $v_Test = ' & $v_Test  & @CRLF)

    $v_Test = Json_ObjExists($_WD_CAPS__OBJECT, 'capabilities.firstMatch')
    ConsoleWrite("- " & @ScriptLineNumber &  ' $v_Test = ' & $v_Test  & @CRLF)

    $v_Test = Json_ObjExists($_WD_CAPS__OBJECT, '[capabilities][alwaysMatch]')
    ConsoleWrite("- " & @ScriptLineNumber &  ' $v_Test = ' & $v_Test  & @CRLF)

    $v_Test = Json_ObjExists($_WD_CAPS__OBJECT, 'capabilities.alwaysMatch')
    ConsoleWrite("- " & @ScriptLineNumber &  ' $v_Test = ' & $v_Test  & @CRLF)

EndFunc   ;==>test5

 

Edited by mLipok

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
Share on other sites

Using Json_ObjExists() I get err that variable must be object.

Should we check IsObj() like this:
 

Func Json_ObjExists(ByRef $Object, $Key)
    If Not IsObj($Object) Then Return False

?

 

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 * How to ask ChatGPT for AutoIt Codefor 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) * Show_Macro_Values.au3 *

 

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: 2023-04-24

Link to comment
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
 Share

×
×
  • Create New...