Popular Post TheXman Posted January 19, 2019 Popular Post Share Posted January 19, 2019 (edited) 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://jqlang.github.io/jq/ jq Manual: https://jqlang.github.io/jq/manual/ jqWiki (FAQ, Cookbook, Advanced Topics) https://github.com/jqlang/jq/wiki 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. 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 is only needed if the jq executale is not in the PATH or @ScriptDir _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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" ;Initialize jq environment _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. You can find several more examples and play around with them or create your own using jqPlayground. jqPlayground is a separate, stand alone, interactive tool for creating, testing and learning JSON processing using jq. 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. >>> Download the UDF in the Files Section <<< Edited November 5, 2023 by TheXman Updated jq documentation links to point to the new repository Skysnake, Danyfirex, Zedna and 4 others 3 4 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
TheXman Posted January 19, 2019 Author Share Posted January 19, 2019 (edited) Version History v1.7.0 Internal code optimizations Increased query speed jqExec() and _jqExecFile() now accept string filters with comments (#), as if they were passed in from a file using the -f or --from-file option. v1.6.2 (2022-11-30) jq_example_2.au3 Modified the script's logging logic to use an internal GUI instead of Notepad. This eliminates the need for Win11-specific logic since Win11's Notepad uses a different edit control than prior versions. (Thanks @Danp2for pointing out the change in Win11's Notepad.) No changes were made to the jq.au3 UDF file. v1.6.1 (2022-10-03) Added the ability to recognize the "--from-file" option. Previously, it would only recognize the "-f" version of the option. Ensured that, in all cases, the JSON string passed to _jqExec() is processed as UTF-8. v1.6.0 (2021-10-02) Added an option to jqDump() and jqDumpFile() that allows you to specify the output notion format. (Bracket-Notation or Dot-Notation) Change the default output notation of jqDump() and jqDumpFile() from bracket-notation to dot-notation. v1.5.0 (2021-09-30) Fixed a bug in jqDump() and jqDumpFile that was skipping values that were equal to boolean false. v1.4.3 (2021-01-22) Modified jqExec() and jqExecFile so that when using the option to pass a jq filter file (-f), the adding of the string filter to the command line is suppressed. Previously, the results would have been correct but the result would have included an error message saying that it couldn't open a file. v1.4.2 (2021-01-10) Modified the path to the executable in the jq_example_2.au3 file. It was pointing to my local directory instead of pointing, generically, to the UDF directory. That would have caused some to initially be confused because the example script would have exited with an error saying that it could not find the executable. v1.4.1 (2021-01-06) Added an additional example file (jq_examples_2.au3) with its associated json data file (nfl_scores_2018_week_01.json). The new examples further highlight the differences between JSON parsers (like the great json.au3 UDF that is based on jsmn) and JSON processors like jq. Read the information at the top of the new example file for more details about the differences and when you may want to use a JSON processor over a JSON parser. Edited February 23, 2023 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 27, 2019 Share Posted March 27, 2019 (edited) jq.au3" (431) : ==> $sCmdLine = StringFormat('"%s"', $__jq_gsJqExeFilePath) ^ ERROR Edited March 27, 2019 by Letraindusoir Link to comment Share on other sites More sharing options...
TheXman Posted March 27, 2019 Author Share Posted March 27, 2019 (edited) I do not encounter any errors when running any of the examples and haven't encountered any such error using the UDF in any of my other scripts. Please provide a script that reproduces the error. Edited March 27, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 28, 2019 Share Posted March 28, 2019 On 3/27/2019 at 9:36 PM, TheXman said: I do not encounter any errors when running any of the examples and haven't encountered any such error using the UDF in any of my other scripts. Please provide a script that reproduces the error. #include "jq.au3" Local $sJson = _ '[{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"1178","ORGAN_CODE":"28591XPSS800416","CARDNO":"455872212281239995","ID":"319352E00E934269977B294A4A8C866F","DOSE_UNIT":"ml","YPZH":"1178","VIS_S_NO":"754262","USEWAY_CODE":"1","LAST_DAYS":"1","RX_DT":1522198703000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"C6H7NAO2","IDCARD":"455872122812999523","PACK_UNIT":"BOX","CREATE_INSTNAME":"","CREATE_DATE":1522847958000,"CARDTYPECODE":"1","PRUDUCT_AMT":"100.8","USEWAY_CODE_NAME":"DISSOLVE","AUTHORORGANIZATION_CODE":"28591XPSS800416","PRUDUCT_P":"25.2","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"754262","UPDATE_DATE":1523959163000,"PRE_IDENT":"1","FORM_CODE_NAME":"SOLUTION","PRUDUCT_FRY":"tid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"1000ml*6","FORM_CODE":"4","CREATE_INSTCODE":"98251","USER_NAME":"ADDITIVE","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"C6H7NAO2","SINGLE_DOSE":"200","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1538262","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1538262","DOC_IDCARD":" ","SEXNAME":"FEMALE"},{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"3572","ORGAN_CODE":"28591XPSS800416","CARDNO":"995221245587928123","ID":"E41B24A453634FA2C717DF9C46650028","DOSE_UNIT":"mg","YPZH":"3572","FAC_NAME":"CHEMGUIDEE","VIS_S_NO":"750670","USEWAY_CODE":"1","LAST_DAYS":"7","RX_DT":1521275855000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"SORBICACIDSODIUMSALT ","IDCARD":"455879995221228123","PACK_UNIT":"BOTTLE","CREATE_INSTNAME":"","CREATE_DATE":1522847948000,"CARDTYPECODE":"1","PRUDUCT_AMT":"163.8","AUTHORORGANIZATION_CODE":"28591XPSS800416","USEWAY_CODE_NAME":"DISSOLVE","PRUDUCT_P":"40.95","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"750670","UPDATE_DATE":1522846316000,"PRE_IDENT":"1","FORM_CODE_NAME":"CASPUSLR","PRUDUCT_FRY":"bid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"20mg*14","FORM_CODE":"143","CREATE_INSTCODE":"98251","USER_NAME":"PRODSUPPLER","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"SORBICACIDSODIUMSALT ","SINGLE_DOSE":"20","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1530200","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1530200","DOC_IDCARD":" ","SEXNAME":"FEMALE"}]' & @CRLF & _ '' Consolewrite(@CRLF & "$sJson=" & $sJson & @CRLF) _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) local $sOut = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sOut & @CRLF) Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 28, 2019 Share Posted March 28, 2019 (edited) run environment SciTE version: 3.6.0 operating system:Microsoft Windows 7 x86 Edition Edited March 28, 2019 by Letraindusoir Link to comment Share on other sites More sharing options...
TheXman Posted March 28, 2019 Author Share Posted March 28, 2019 (edited) @Letraindusoir I cannot reproduce your error. Maybe you have a corrupt version of the UDF file. Have you modified the UDF file in ANY way? I ran the script below and it runs just fine. #include "jq.au3" $sJson = _ '[{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"1178","ORGAN_CODE":"28591XPSS800416","CARDNO":"455872212281239995","ID":"319352E00E934269977B294A4A8C866F","DOSE_UNIT":"ml","YPZH":"1178","VIS_S_NO":"754262","USEWAY_CODE":"1","LAST_DAYS":"1","RX_DT":1522198703000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"C6H7NAO2","IDCARD":"455872122812999523","PACK_UNIT":"BOX","CREATE_INSTNAME":"","CREATE_DATE":1522847958000,"CARDTYPECODE":"1","PRUDUCT_AMT":"100.8","USEWAY_CODE_NAME":"DISSOLVE","AUTHORORGANIZATION_CODE":"28591XPSS800416","PRUDUCT_P":"25.2","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"754262","UPDATE_DATE":1523959163000,"PRE_IDENT":"1","FORM_CODE_NAME":"SOLUTION","PRUDUCT_FRY":"tid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"1000ml*6","FORM_CODE":"4","CREATE_INSTCODE":"98251","USER_NAME":"ADDITIVE","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"C6H7NAO2","SINGLE_DOSE":"200","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1538262","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1538262","DOC_IDCARD":" ","SEXNAME":"FEMALE"},{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"3572","ORGAN_CODE":"28591XPSS800416","CARDNO":"995221245587928123","ID":"E41B24A453634FA2C717DF9C46650028","DOSE_UNIT":"mg","YPZH":"3572","FAC_NAME":"CHEMGUIDEE","VIS_S_NO":"750670","USEWAY_CODE":"1","LAST_DAYS":"7","RX_DT":1521275855000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"SORBICACIDSODIUMSALT ","IDCARD":"455879995221228123","PACK_UNIT":"BOTTLE","CREATE_INSTNAME":"","CREATE_DATE":1522847948000,"CARDTYPECODE":"1","PRUDUCT_AMT":"163.8","AUTHORORGANIZATION_CODE":"28591XPSS800416","USEWAY_CODE_NAME":"DISSOLVE","PRUDUCT_P":"40.95","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"750670","UPDATE_DATE":1522846316000,"PRE_IDENT":"1","FORM_CODE_NAME":"CASPUSLR","PRUDUCT_FRY":"bid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"20mg*14","FORM_CODE":"143","CREATE_INSTCODE":"98251","USER_NAME":"PRODSUPPLER","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"SORBICACIDSODIUMSALT ","SINGLE_DOSE":"20","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1530200","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1530200","DOC_IDCARD":" ","SEXNAME":"FEMALE"}]' Consolewrite(@CRLF & "$sJson=" & $sJson & @CRLF) _jqInit("C:\Portable Apps\AutoIt3\Include\MyIncludes\JQ\jq-win64.exe") ;<== Parameter is not needed if jq executable is in current dir or path If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sOut = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sOut & @CRLF) $sOut = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sOut & @CRLF) Output: expandcollapse popup$sJson=[{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"1178","ORGAN_CODE":"28591XPSS800416","CARDNO":"455872212281239995","ID":"319352E00E934269977B294A4A8C866F","DOSE_UNIT":"ml","YPZH":"1178","VIS_S_NO":"754262","USEWAY_CODE":"1","LAST_DAYS":"1","RX_DT":1522198703000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"C6H7NAO2","IDCARD":"455872122812999523","PACK_UNIT":"BOX","CREATE_INSTNAME":"","CREATE_DATE":1522847958000,"CARDTYPECODE":"1","PRUDUCT_AMT":"100.8","USEWAY_CODE_NAME":"DISSOLVE","AUTHORORGANIZATION_CODE":"28591XPSS800416","PRUDUCT_P":"25.2","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"754262","UPDATE_DATE":1523959163000,"PRE_IDENT":"1","FORM_CODE_NAME":"SOLUTION","PRUDUCT_FRY":"tid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"1000ml*6","FORM_CODE":"4","CREATE_INSTCODE":"98251","USER_NAME":"ADDITIVE","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"C6H7NAO2","SINGLE_DOSE":"200","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1538262","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1538262","DOC_IDCARD":" ","SEXNAME":"FEMALE"},{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"3572","ORGAN_CODE":"28591XPSS800416","CARDNO":"995221245587928123","ID":"E41B24A453634FA2C717DF9C46650028","DOSE_UNIT":"mg","YPZH":"3572","FAC_NAME":"CHEMGUIDEE","VIS_S_NO":"750670","USEWAY_CODE":"1","LAST_DAYS":"7","RX_DT":1521275855000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"SORBICACIDSODIUMSALT ","IDCARD":"455879995221228123","PACK_UNIT":"BOTTLE","CREATE_INSTNAME":"","CREATE_DATE":1522847948000,"CARDTYPECODE":"1","PRUDUCT_AMT":"163.8","AUTHORORGANIZATION_CODE":"28591XPSS800416","USEWAY_CODE_NAME":"DISSOLVE","PRUDUCT_P":"40.95","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"750670","UPDATE_DATE":1522846316000,"PRE_IDENT":"1","FORM_CODE_NAME":"CASPUSLR","PRUDUCT_FRY":"bid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"20mg*14","FORM_CODE":"143","CREATE_INSTCODE":"98251","USER_NAME":"PRODSUPPLER","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"SORBICACIDSODIUMSALT ","SINGLE_DOSE":"20","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1530200","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1530200","DOC_IDCARD":" ","SEXNAME":"FEMALE"}] Compact-Print JSON [{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"1178","ORGAN_CODE":"28591XPSS800416","CARDNO":"455872212281239995","ID":"319352E00E934269977B294A4A8C866F","DOSE_UNIT":"ml","YPZH":"1178","VIS_S_NO":"754262","USEWAY_CODE":"1","LAST_DAYS":"1","RX_DT":1522198703000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"C6H7NAO2","IDCARD":"455872122812999523","PACK_UNIT":"BOX","CREATE_INSTNAME":"","CREATE_DATE":1522847958000,"CARDTYPECODE":"1","PRUDUCT_AMT":"100.8","USEWAY_CODE_NAME":"DISSOLVE","AUTHORORGANIZATION_CODE":"28591XPSS800416","PRUDUCT_P":"25.2","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"754262","UPDATE_DATE":1523959163000,"PRE_IDENT":"1","FORM_CODE_NAME":"SOLUTION","PRUDUCT_FRY":"tid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"1000ml*6","FORM_CODE":"4","CREATE_INSTCODE":"98251","USER_NAME":"ADDITIVE","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"C6H7NAO2","SINGLE_DOSE":"200","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1538262","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1538262","DOC_IDCARD":" ","SEXNAME":"FEMALE"},{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"3572","ORGAN_CODE":"28591XPSS800416","CARDNO":"995221245587928123","ID":"E41B24A453634FA2C717DF9C46650028","DOSE_UNIT":"mg","YPZH":"3572","FAC_NAME":"CHEMGUIDEE","VIS_S_NO":"750670","USEWAY_CODE":"1","LAST_DAYS":"7","RX_DT":1521275855000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"SORBICACIDSODIUMSALT ","IDCARD":"455879995221228123","PACK_UNIT":"BOTTLE","CREATE_INSTNAME":"","CREATE_DATE":1522847948000,"CARDTYPECODE":"1","PRUDUCT_AMT":"163.8","AUTHORORGANIZATION_CODE":"28591XPSS800416","USEWAY_CODE_NAME":"DISSOLVE","PRUDUCT_P":"40.95","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"750670","UPDATE_DATE":1522846316000,"PRE_IDENT":"1","FORM_CODE_NAME":"CASPUSLR","PRUDUCT_FRY":"bid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"20mg*14","FORM_CODE":"143","CREATE_INSTCODE":"98251","USER_NAME":"PRODSUPPLER","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"SORBICACIDSODIUMSALT ","SINGLE_DOSE":"20","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1530200","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1530200","DOC_IDCARD":" ","SEXNAME":"FEMALE"}] Pretty-Print JSON [ { "UPDATE_INSTCODE": "98251", "AUTHORORGANIZATION_TEXT": "Enterprise consulting service organization", "PRODUCT_CODE": "1178", "ORGAN_CODE": "28591XPSS800416", "CARDNO": "455872212281239995", "ID": "319352E00E934269977B294A4A8C866F", "DOSE_UNIT": "ml", "YPZH": "1178", "VIS_S_NO": "754262", "USEWAY_CODE": "1", "LAST_DAYS": "1", "RX_DT": 1522198703000, "UPDATE_INSTNAME": "", "PRUDUCT_NAME": "C6H7NAO2", "IDCARD": "455872122812999523", "PACK_UNIT": "BOX", "CREATE_INSTNAME": "", "CREATE_DATE": 1522847958000, "CARDTYPECODE": "1", "PRUDUCT_AMT": "100.8", "USEWAY_CODE_NAME": "DISSOLVE", "AUTHORORGANIZATION_CODE": "28591XPSS800416", "PRUDUCT_P": "25.2", "SEXCODE": "2", "TOTAL_DOSE": "20", "OP_EM_HP_NO": "754262", "UPDATE_DATE": 1523959163000, "PRE_IDENT": "1", "FORM_CODE_NAME": "SOLUTION", "PRUDUCT_FRY": "tid", "CLIENT_NAME": "ANTICORROSIVE", "OP_EM_HP_MARK": "1", "CARDTYPENAME": "INSURENCE", "PRUDUCT_SPEC": "1000ml*6", "FORM_CODE": "4", "CREATE_INSTCODE": "98251", "USER_NAME": "ADDITIVE", "PROCDUTDATE": -389779200000, "PACK_NO": "4", "TRADE_NAME": "C6H7NAO2", "SINGLE_DOSE": "200", "ORGAN_NAME": "Enterprise consulting service organization", "MPI": "0", "ID2": "1538262", "RX_TYPE": "1", "RX_TYPE_NAME": " INSECTICIDE", "RX_CODE": "1538262", "DOC_IDCARD": " ", "SEXNAME": "FEMALE" }, { "UPDATE_INSTCODE": "98251", "AUTHORORGANIZATION_TEXT": "Enterprise consulting service organization", "PRODUCT_CODE": "3572", "ORGAN_CODE": "28591XPSS800416", "CARDNO": "995221245587928123", "ID": "E41B24A453634FA2C717DF9C46650028", "DOSE_UNIT": "mg", "YPZH": "3572", "FAC_NAME": "CHEMGUIDEE", "VIS_S_NO": "750670", "USEWAY_CODE": "1", "LAST_DAYS": "7", "RX_DT": 1521275855000, "UPDATE_INSTNAME": "", "PRUDUCT_NAME": "SORBICACIDSODIUMSALT ", "IDCARD": "455879995221228123", "PACK_UNIT": "BOTTLE", "CREATE_INSTNAME": "", "CREATE_DATE": 1522847948000, "CARDTYPECODE": "1", "PRUDUCT_AMT": "163.8", "AUTHORORGANIZATION_CODE": "28591XPSS800416", "USEWAY_CODE_NAME": "DISSOLVE", "PRUDUCT_P": "40.95", "SEXCODE": "2", "TOTAL_DOSE": "20", "OP_EM_HP_NO": "750670", "UPDATE_DATE": 1522846316000, "PRE_IDENT": "1", "FORM_CODE_NAME": "CASPUSLR", "PRUDUCT_FRY": "bid", "CLIENT_NAME": "ANTICORROSIVE", "OP_EM_HP_MARK": "1", "CARDTYPENAME": "INSURENCE", "PRUDUCT_SPEC": "20mg*14", "FORM_CODE": "143", "CREATE_INSTCODE": "98251", "USER_NAME": "PRODSUPPLER", "PROCDUTDATE": -389779200000, "PACK_NO": "4", "TRADE_NAME": "SORBICACIDSODIUMSALT ", "SINGLE_DOSE": "20", "ORGAN_NAME": "Enterprise consulting service organization", "MPI": "0", "ID2": "1530200", "RX_TYPE": "1", "RX_TYPE_NAME": " INSECTICIDE", "RX_CODE": "1530200", "DOC_IDCARD": " ", "SEXNAME": "FEMALE" } ] Edited March 28, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 29, 2019 Share Posted March 29, 2019 19 hours ago, TheXman said: @Letraindusoir I cannot reproduce your error. Maybe you have a corrupt version of the UDF file. Have you modified the UDF file in ANY way? I ran the script below and it runs just fine. #include "jq.au3" $sJson = _ '[{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"1178","ORGAN_CODE":"28591XPSS800416","CARDNO":"455872212281239995","ID":"319352E00E934269977B294A4A8C866F","DOSE_UNIT":"ml","YPZH":"1178","VIS_S_NO":"754262","USEWAY_CODE":"1","LAST_DAYS":"1","RX_DT":1522198703000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"C6H7NAO2","IDCARD":"455872122812999523","PACK_UNIT":"BOX","CREATE_INSTNAME":"","CREATE_DATE":1522847958000,"CARDTYPECODE":"1","PRUDUCT_AMT":"100.8","USEWAY_CODE_NAME":"DISSOLVE","AUTHORORGANIZATION_CODE":"28591XPSS800416","PRUDUCT_P":"25.2","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"754262","UPDATE_DATE":1523959163000,"PRE_IDENT":"1","FORM_CODE_NAME":"SOLUTION","PRUDUCT_FRY":"tid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"1000ml*6","FORM_CODE":"4","CREATE_INSTCODE":"98251","USER_NAME":"ADDITIVE","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"C6H7NAO2","SINGLE_DOSE":"200","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1538262","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1538262","DOC_IDCARD":" ","SEXNAME":"FEMALE"},{"UPDATE_INSTCODE":"98251","AUTHORORGANIZATION_TEXT":"Enterprise consulting service organization","PRODUCT_CODE":"3572","ORGAN_CODE":"28591XPSS800416","CARDNO":"995221245587928123","ID":"E41B24A453634FA2C717DF9C46650028","DOSE_UNIT":"mg","YPZH":"3572","FAC_NAME":"CHEMGUIDEE","VIS_S_NO":"750670","USEWAY_CODE":"1","LAST_DAYS":"7","RX_DT":1521275855000,"UPDATE_INSTNAME":"","PRUDUCT_NAME":"SORBICACIDSODIUMSALT ","IDCARD":"455879995221228123","PACK_UNIT":"BOTTLE","CREATE_INSTNAME":"","CREATE_DATE":1522847948000,"CARDTYPECODE":"1","PRUDUCT_AMT":"163.8","AUTHORORGANIZATION_CODE":"28591XPSS800416","USEWAY_CODE_NAME":"DISSOLVE","PRUDUCT_P":"40.95","SEXCODE":"2","TOTAL_DOSE":"20","OP_EM_HP_NO":"750670","UPDATE_DATE":1522846316000,"PRE_IDENT":"1","FORM_CODE_NAME":"CASPUSLR","PRUDUCT_FRY":"bid","CLIENT_NAME":"ANTICORROSIVE","OP_EM_HP_MARK":"1","CARDTYPENAME":"INSURENCE","PRUDUCT_SPEC":"20mg*14","FORM_CODE":"143","CREATE_INSTCODE":"98251","USER_NAME":"PRODSUPPLER","PROCDUTDATE":-389779200000,"PACK_NO":"4","TRADE_NAME":"SORBICACIDSODIUMSALT ","SINGLE_DOSE":"20","ORGAN_NAME":"Enterprise consulting service organization","MPI":"0","ID2":"1530200","RX_TYPE":"1","RX_TYPE_NAME":" INSECTICIDE","RX_CODE":"1530200","DOC_IDCARD":" ","SEXNAME":"FEMALE"}]' Consolewrite(@CRLF & "$sJson=" & $sJson & @CRLF) _jqInit("C:\Portable Apps\AutoIt3\Include\MyIncludes\JQ\jq-win64.exe") ;<== Parameter is not needed if jq executable is in current dir or path If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sOut = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sOut & @CRLF) $sOut = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sOut & @CRLF) Thanks! Run the above code,New problems have arisen..... I think there's a problem with the version of autoit or scite ? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 29, 2019 Developers Share Posted March 29, 2019 58 minutes ago, Letraindusoir said: I think there's a problem with the version of autoit or scite ? and you think this ...why? You also never told us if it is now working for you and how you solved your previous issue... care to share? Jos 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 More sharing options...
Letraindusoir Posted March 29, 2019 Share Posted March 29, 2019 2 hours ago, Letraindusoir said: Thanks! Run the above code,New problems have arisen..... I think there's a problem with the version of autoit or scite ? sorry,It 's my mistake. _jqInit("C:\Portable Apps\AutoIt3\Include\MyIncludes\JQ\jq-win64.exe") ;<== Parameter is not needed if jq executable is in current dir or path on my here, jq executable is in Scriptdir.so,It should be: _jqInit() Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 29, 2019 Share Posted March 29, 2019 But oddly enough, the same script, which was retested today, was all running fine, and I didn't make any corrections.I don't know why. Link to comment Share on other sites More sharing options...
water Posted June 14, 2020 Share Posted June 14, 2020 The UDF has been added to the wiki. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
qsek Posted September 21, 2020 Share Posted September 21, 2020 (edited) In jqInit() the code for searching the jq-winXX.exe files is not language proof. You use the "where" command to search for the files in the @ScriptDir $iPid = Run(StringFormat("where jq-win%s.exe", $s32or64), @ScriptDir, @SW_HIDE, $STDERR_MERGED) But the return of where.exe can be localized depending of OS language. for example in my german OS, jqInit() does not give an error although no file has been found: $sExePath = _jqInit() If @error Then ConsoleWrite(StringFormat("ERROR: Unable to initialize jq - @error = %s", @error) & @CRLF) Exit -1 EndIf ConsoleWrite(StringFormat("jq Path = %s", $sExePath) & @CRLF) ConsoleWrite(StringFormat("jq UDF Version = %s", _jqUdfVersion()) & @CRLF) ConsoleWrite(StringFormat("jq Version = %s", _jqVersion()) & @CRLF) Quote jq Path = INFORMATION: Es konnten keine Dateien mit dem angegebenen jq UDF Version = 1.4.0 jq Version = ERROR: Unable to execute jq jq_debug_log.txt: Quote 2020-09-21 17:10:19 Searching for jq executable 2020-09-21 17:10:19 jq executable found = INFORMATION: Es konnten keine Dateien mit dem angegebenen I suggest you use a simple FileExists if no Path was supplied: expandcollapse popup;If exe path was supplied If StringStripWS($sExePath, $STR_STRIPLEADING + $STR_STRIPTRAILING ) <> "" Then If $__jq_gbDebugging Then __jqWriteLogLine(StringFormat("Exe path supplied to _jqInit = %s", $sExePath)) ;If the file does not exist If Not FileExists($sExePath) Then Return SetError(2, 0, "") ;Set global var and return $__jq_gsJqExeFilePath = $sExePath Else If $__jq_gbDebugging Then __jqWriteLogLine("Searching for jq executable") $sExePath = @ScriptDir&"\jq-win"&$s32or64&".exe" If Not FileExists($sExePath) Then If $__jq_gbDebugging Then __jqWriteLogLine("jq executable not found") Return SetError(2, 0, "") EndIf If $__jq_gbDebugging Then __jqWriteLogLine(StringFormat("jq executable found = %s", $sExePath)) $__jq_gsJqExeFilePath = $sExePath ;~ not OS language proof ;~ ;Search for exe ;~ $iPid = Run(StringFormat("where jq-win%s.exe", $s32or64), @ScriptDir, @SW_HIDE, $STDERR_MERGED) ;~ If @error Then Return SetError(3, 0, "") ;~ ;Wait for command to close and get output ;~ ProcessWaitClose($iPid, 10) ;~ $sCmdOutput = StdoutRead($iPid) ;~ ConsoleWrite($sCmdOutput & @CRLF) ;~ ;If exe not found ;~ If StringInStr($sCmdOutput, "Could not find") Then ;~ If $__jq_gbDebugging Then __jqWriteLogLine("jq executable not found") ;~ Return SetError(1, 0, "") ;~ EndIf ;~ ;Parse first line from output ;~ $aResult = StringRegExp($sCmdOutput, ".*", 3) ;~ If Not IsArray($aResult) Then Return SetError(1, 0, "") ;~ ;Set global var ;~ If $__jq_gbDebugging Then __jqWriteLogLine(StringFormat("jq executable found = %s", $aResult[0])) ;~ $__jq_gsJqExeFilePath = $aResult[0] EndIf Is there a reason you do the whole Run/where/StdoutRead block when no Path was supplied? Edited September 21, 2020 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
qsek Posted September 21, 2020 Share Posted September 21, 2020 Also i would add that this command line approach is quite slow. I got 500 ms+ for each query. Can be very slow if you have loops with queries. Isn't there a COM or DLL version? Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
TheXman Posted September 21, 2020 Author Share Posted September 21, 2020 (edited) 36 minutes ago, qsek said: Also i would add that this command line approach is quite slow. If you read the first post, I said that if you only need to parse JSON, then there are faster solutions. jq is a JSON PROCESSOR not just a PARSER. So if you need to actually do some processing of JSON, it is much faster, easier, and will save numerous lines of code. For example, I have a NFL pool that automatically updates its scores. The source is a large JSON file that I access by web API. It has all of the matchups, scores, and stats for the current week's games, in realtime. In 1 jq call (one line of executable code), I can filter just the games that have completed so far, get the winning teams, and the scores. Being able to do it in under 1 second is much better than all of the logic that would be required to do the same thing after parsing the necessary data and the using AutoIt to process all of that parsed data to get the required results. Processing JSON and parsing JSON data are 2 totally different things. If you are doing any calculations or transformations of the JSON in your loop, then it could probably all be done with a single jq call (at least the JSON part). That's the difference between parsing and processing the JSON. 36 minutes ago, qsek said: Isn't there a COM or DLL version? I haven't found one. It is open source so if you have the skill, you could always write your own DLL or COM wrapper. Edited September 21, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
ptrex Posted September 22, 2020 Share Posted September 22, 2020 @qsek If you don't find a COM or DLL you can always turn to PS. Example : Quote $sJson = '{"fruits":[{"Apple":{"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' | ConvertFrom-Json $sJson.fruits | select -expand * Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
mLipok Posted September 22, 2020 Share Posted September 22, 2020 (edited) 22 hours ago, qsek said: Isn't there a COM or DLL version? https://www.chilkatsoft.com/refdoc/xChilkatJsonArrayRef.html No License Required for JsonArray https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html No License Required for JsonObject And AutoIt UDF: Edited September 22, 2020 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 Code * 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 API * ErrorLog.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 TaskScheduler * IE 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 stuff * OnHungApp handler * Avoid "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" , 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 More sharing options...
TheXman Posted January 6, 2021 Author Share Posted January 6, 2021 (edited) What's New in v1.4.1 Added an additional example file (jq_examples_2.au3) with its associated json data file (nfl_scores_2018_week_01.json). The new examples further highlight the differences between JSON parsers (like the great json.au3 UDF that is based on jsmn) and JSON processors like jq. Read the information at the top of the new example file for more details about the differences and when you may want to use a JSON processor over a JSON parser. Edited January 6, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
TheXman Posted January 10, 2021 Author Share Posted January 10, 2021 (edited) New version uploaded. Click HERE to see version history. Edited January 10, 2021 by TheXman Musashi 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Danp2 Posted November 13, 2022 Share Posted November 13, 2022 FYI, the latest version of Notepad has an edit control of class RichEditD2DPT so write_log_line() in jq_examples_2 fails to output any results. TheXman 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now