Sascha Posted March 11 Share Posted March 11 Hello, is there any reason why i can't make this example from the german forum output the array size? #include <JSON.au3> Example4() Func Example4() ConsoleWrite(@CRLF & @CRLF) ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" & @CRLF) Local $sJSONTest = '[{"_object": "typ","card": "test1"},{"_object": "typ","card": "test2"},{"_object": "typ","card": "test3"},{"_object": "typ","card": "test4"}]' Local $o_Object = _JSON_Parse($sJSONTest) ConsoleWrite("$o_Object: " & _JSON_Generate($o_Object) & @CRLF) $vTmp = _JSON_Get($o_Object, "[1]") ConsoleWrite("$vTmp: " & _JSON_Generate($vTmp) & @CRLF) ConsoleWrite("$vTmp.Count: " & $vTmp.Count & @CRLF) ;Hier würde ich gerne alle enthaltenden ITEMS zählen, in dem Beispiel wären es 4 und in einer Schleife einzeln durchgehen EndFunc I can see no value for $vTmp.Count. Regards Sascha Link to comment Share on other sites More sharing options...
Solution OJBakker Posted March 11 Solution Share Posted March 11 The variable $vTmp is of type Map, so you have to use Ubound($vTmp). Link to comment Share on other sites More sharing options...
ioa747 Posted March 11 Share Posted March 11 #include <JSON.au3> ; https://www.autoitscript.com/forum/topic/209502-json-udf-in-pure-autoit/?tab=comments#comment-1512704 Example4() Func Example4() ConsoleWrite(@CRLF & @CRLF) ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" & @CRLF) Local $sJSONTest = '[{"_object": "typ","card": "test1"},{"_object": "typ","card": "test2"},{"_object": "typ","card": "test3"},{"_object": "typ","card": "test4"}]' Local $o_Object = _JSON_Parse($sJSONTest) ConsoleWrite("$o_Object cnt=" & UBound($o_Object) & @CRLF & @CRLF) For $i = 0 To UBound($o_Object, 1) - 1 $mMap = _JSON_Get($o_Object, "[" & $i & "]") ConsoleWrite($i & ") $mMap cnt=" & UBound($mMap) & @CRLF) Local $aMapKeys = MapKeys($mMap) For $vKey In $aMapKeys ConsoleWrite("-- Key: " & $vKey) ConsoleWrite(@TAB & "Value: " & $mMap[$vKey]) ConsoleWrite(@TAB & "Variable Type: " & VarGetType($vKey) & @CRLF) Next ConsoleWrite("" & @CRLF) Next ;Hier würde ich gerne alle enthaltenden ITEMS zählen, in dem Beispiel wären es 4 und in einer Schleife einzeln durchgehen EndFunc ;==>Example4 if you want more follow the link below and have a look at Reveal hidden contents Link to comment Share on other sites More sharing options...
AspirinJunkie Posted March 11 Share Posted March 11 3 hours ago, Sascha said: I can see no value for $vTmp.Count. In the old version of this udf i used the Scripting.Dictionary to implement a json object. Since maps are part of the stable releases of AutoIt i switched to the inbuild map datatype. So in former versions you have to use .Count because a Dictionary is used and in the current versions you have to use Ubound() because objects are implemented as AutoIt-Maps. Link to comment Share on other sites More sharing options...
Sascha Posted March 17 Author Share Posted March 17 I got it working now. Thank you for your help. 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