JSONgen (JSON generator) 1.0.0

   (0 reviews)

About This File

UDF to generate JSON.

Example:
#include "JSONgen.au3"

$oJson = New_Json()

; Let's add some stand-alone elements
Json_AddElement($oJson, "test") ; A string
Local $aArray[2] = ['hai', 'halo']
Json_AddElement($oJson, $aArray) ; An array

; Let's add some associative elements
Json_AddElement($oJson, "hey", 2.55)
Json_AddElement($oJson, "delete", "me") ; We will delete this one
Json_AddElement($oJson, "hoo", True)
Json_AddElement($oJson, "edit", "this") ; And edit this one

; Let's do some editing
Json_DeleteElement($oJson, "delete") ; Deleting that one
Json_EditElement($oJson, "edit", "that") ; Editing that one

; Let's now add an associated (non-associative) array :)
Local $aArray[2] = ['hey', 'bye']
Json_AddElement($oJson, 'array', $aArray)

; Now we get the JSON
$sTheJsonCode = Json_GetJson($oJson)

MsgBox(0, "Json code", $sTheJsonCode)




User Feedback

You may only provide a review once you have downloaded the file.

There are no reviews to display.

  • Similar Content

    • genius257
      Is it possible to throw an error in a ScriptControl object, via AutoIt
      By genius257
      First of all I've been searching on the forum, and while there's been done something like this with: https://www.autoitscript.com/forum/topic/141004-comobject-proxy-seamless-windows-script-control-autoitobj/
      I could not find any solution to my predicament.
       
      Is it possible to throw an error in a ScriptControl object, via AutoIt?
      I have a script, where AutoIt calls ScriptControl:JavaScript which in turn calls AutoIt.
      However i would like to be able to make AutoIt invoke an exception within ScriptControl, if the called functionality fails.
      Here's some code for reference:
      #AutoIt3Wrapper_Run_AU3Check=n #include-once #include "AutoitObject.au3" #include <WinAPIDiag.au3> $oJS = ObjCreate("ScriptControl") $oJS.Language = "JScript" $oJS.TimeOut = 0; A value of 0 means that the ScriptControl will monitor the execution of the script and will trigger the Timeout event if it determines that the script is hung. _AutoItObject_Startup() $oAutoIt = _AutoItObject_Create() _AutoItObject_AddMethod($oAutoIt, "Execute", "_Execute", False) $oJS.AddObject("AutoIt", $oAutoIt, True) OnAutoItExitRegister("_CleanUp") $_AutoItError = ObjEvent("AutoIt.Error", "_AutoItError") Func _CleanUp() ConsoleWrite("Cleaning up..."&@CRLF) $oJS = 0 $oAutoIt = 0 _AutoItObject_Shutdown() EndFunc Func _Execute($oSelf, $sString) $vReturn = Execute($sString) If @error<>0 Then Return $oJS.Eval("throw new SyntaxError();"); Does invoke exception, but not within the try/catch Return $vReturn EndFunc Func _AutoItError($oError) $oError2 = $oJS.Error ConsoleWrite( _ "Column: " & $oError2.Column & @CRLF & _ "Description: " & $oError2.Description & @CRLF & _ "HelpContext: " & $oError2.HelpContext & @CRLF & _ "HelpFile: " & $oError2.HelpFile & @CRLF & _ "Line: " & $oError2.Line & @CRLF & _ "Number: " & $oError2.Number & @CRLF & _ "Source: " & $oError2.Source & @CRLF & _ "Text: " & $oError2.Text & @CRLF _ ) $oError2.Clear() EndFunc $oJS.Eval("(function(){"& _ "try{"& _ "AutoIt.Execute('MsgBox(0,\'\', \'a\')');"& _ "AutoIt.Execute('a.b');/*error should occur here*/"& _ "AutoIt.Execute('MsgBox(0,\'\', \'b\')');"& _ "}catch(e){"& _ "AutoIt.Execute('ConsoleWrite(\'Error\'&@CRLF)');"& _ "}"& _ "})()")  
    • Robdog1955
      Enter data into IE form that has a javascript editbox
      By Robdog1955
      I am trying to use IE.au3 UDF to auto fill a webpage. All goes well until I get to an editbox that appears to be a javascript. I am attaching a pic of the editbox. (I would be glad to add any other information needed to help me past this last hurdle in my script. I'm just not sure what questions you have to help me with this.)

    • Leo1906
      how to properly delete embedded iexplore object
      By Leo1906
      I have a problem here. I have a Script wich opens a Gui with an iExplore Object embedded. The GuiCreate is in an external Function an called in the main while of the script.
      When the Gui closes the Gui gets destoyed. But unfortunately the iExplore Obejct still remains. You can see this by the RAM usage of the exe. After opening a Website the RAM usage stays at  ~ 50 Mb RAM (depending on the website).
      I want it to fall back to the normal state (around 4 MB).
      You can see my attempts to delete the object properly. According to the help an embedded object should get deleted when the GUI gets deleted ...?
       
      GUICreate("Display", 600, 360, -1, -1) Local $oIE = _IECreateEmbedded() $obj = GUICtrlCreateObj($oIE, 0, 0, 600, 360) GUICtrlSetColor(-1, 0xff0000) _IEPropertySet($oIE, "addressbar", False) _IEPropertySet($oIE, "menubar", False) _IEPropertySet($oIE, "statusbar", False) _IEPropertySet($oIE, "toolbar", False) _IEPropertySet($oIE, "resizable", False) _IENavigate($oIE, $dest&"\index.html") GUISetState(@SW_SHOW) While 1 Local $iMsg = GUIGetMsg() Local $tmsg = TrayGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ;~ $obj = 0 ;~ _WinAPI_DeleteObject ( $obj ) ;~ _IEQuit($obj) ;~ _MemGlobalFree($obj) ;~ $oIE = 0 ;~ _WinAPI_DeleteObject ( $oIE ) ;~ _IEQuit($oIE) ;~ _MemGlobalFree($oIE) GUIDelete() Case $tmsg = $exit _exit() EndSelect WEnd  
      I would be very happy for your help  
      Kind regards
    • DrewSS
      javascript menu automation help - _FFCmd
      By DrewSS
      Hello,
      I'm looking for some direction with how to automate the exporting of an excel report through a javascript driven menu; unfortunately it does not support IE, so Firefox is what i've been trying, and I can navigate all the way through the dashboard and generate the report, but to export it I need to go through the menu. The menu has onmousedown and onmouseover events that I'm not sure how to send. It looks like I can do this with _FFCmd, but it may take several statements.. can someone help me get started?
       
      This is the path to export:
       
      <div id="mstr395" tstid="" class="mstrmojo-ListBase mstrmojo-ui-Menu unselectable mojo-theme-dark visible" style="top: 0px; right: 100%; bottom: auto; left: auto;"
      onclick="mstrmojo.dom.captureDomEvent('mstr395','click', self, event)"
      ondblclick="mstrmojo.dom.captureDomEvent('mstr395','dblclick', self, event)"
      onmousedown="mstrmojo.dom.captureDomEvent('mstr395','mousedown', self, event)"
      onmouseover="mstrmojo.dom.captureDomEvent('mstr395','mouseover', self, event)"
      onmouseout="mstrmojo.dom.captureDomEvent('mstr395','mouseout', self, event)"
      oncontextmenu="mstrmojo.dom.captureDomEvent('mstr395','contextmenu', self, event)">
      <div class="mstrmojo-ui-Menu-item-container" style="">
      <a class="item exportToExcel mstrmojo-ui-Menu-item" idx="0" style="" title="">
      <div class="micn"></div>Excel</a><a class="item exportToPDF mstrmojo-ui-Menu-item" idx="1" style="" title="">
       
      Sorry I cannot provide access to the dashboard as it has sensitive information. Any feedback is greatly appreciated!
       
       
       
       
       
    • guinness
      imageExists
      By guinness
      Check if an image actually resolves to a successful HTTP status code e.g. 200 (OK). imageExists returns a promise, so make sure the browser you're using supports promises e.g. Chrome. If not, then you can look at using a polyfill (https://github.com/components/es6-promise) or if you're feeling adventurous, then change the code to use jQuery's deferreds (not recommended).
      To see it working, copy the code to http://www.es6fiddle.net/ and watch the images either resolve or fail (reject).
      /*global console, Promise*/ /** * Check if an image is resolvable i.e. returns a HTTP status code that is not 404 * * @param {string} sourceFile An image source file to check * @return {promise} A promise that is resolved/rejected once the image has loaded or a response has been resolved. The source file is passed through */ var imageExists = (function imageExistsModule(document, Promise) { // Append to the global object i.e. window return function imageExists(sourceFile) { if (!sourceFile || !sourceFile.length) { return Promise.reject(sourceFile); } // Create a HTMLImageElement node, but don't insert into the DOM var img = document.createElement('img'); // Set the image element source file img.src = sourceFile; // If the image has already been loaded i.e. cached, then resolve a promise if (img.complete) { return Promise.resolve(sourceFile); } // Return a promise return new Promise(function promise(resolve, reject) { // Create event listeners for when or if the HTMLImageElement is loaded img.addEventListener('error', function errorEvent() { reject(sourceFile); }); img.addEventListener('load', function loadEvent() { resolve(sourceFile); }); }); }; }( document, Promise )); (function example(imageExists, console) { // Check if guinness' thumbnail exists. This returns a promise object imageExists('https://www.autoitscript.com/forum/uploads/profile/photo-thumb-35302.jpg').then(function promiseThen(image) { console.log(image + ' => OKAY'); }).catch(function promiseCatch(image) { console.log(image + ' => FAIL'); }); // Check if a random thumbnail exists. This returns a promise object imageExists('https://www.autoitscript.com/forum/uploads/profile/random-thumb.jpg').then(function promiseThen(image) { console.log(image + ' => OKAY'); }).catch(function promiseCatch(image) { console.log(image + ' => FAIL'); }); }( imageExists, console ));