Developers Jos Posted October 1, 2018 Developers Share Posted October 1, 2018 (edited) @TheXman, I see that there are quit some differences between your "Json.original.au3" file and the json.au3 in the current zip file in the first post. Did you use another version for starters? I do see the issue you report and will look at the fix you propose for that. Jos Edited October 1, 2018 by 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...
Developers Jos Posted October 1, 2018 Developers Share Posted October 1, 2018 Updated first post with merge of the lines needed to fix the reported issue. All other stuff skipped for now. Thanks, 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...
TheXman Posted October 1, 2018 Share Posted October 1, 2018 (edited) @Jos Thanks for applying the fixes related to the json_dump() output. 3 hours ago, Jos said: I see that there are quit some differences between your "" file and the json.au3 in the current zip file in the first post. The rest of the changes were not bug-related so they aren't as important. One of the additional changes was to add a helper function, Json_ObjGetItems(). Json_ObjGetKeys() already existed so it seemed only logical to have a Json_ObjGetItems() too. The other changes are just the declaration of variables before their use. Unfortunately, I'm one of those old school programmers that strives to have a "clean" compile, meaning no warnings. Since I always stipulate that all vars must exist before their use, when compiling scripts with the JSON UDF, it would throw multiple warnings about already declared vars and undeclared vars. So I went through and made sure that all variables were declared only once prior to use. Now the JSON UDF compiles "cleanly" with the strictest compilation directives, "#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d". Again, your efforts towards maintaining the JSON UDF, and AutoIt in general, are greatly appreciated. Edited October 1, 2018 by TheXman Added that I went through and fixed all undeclared and already declared warnings from AU3Check 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...
Developers Jos Posted October 1, 2018 Developers Share Posted October 1, 2018 Ah ok, well this is originally not my code and really only added the JSON_DUMP() function to it as I thought it would be very useful to others. I am fine when we also clean up the code further and make an update for that. I honestly think these UDF's should be added to the standard AutoIt3 distribution but that means somebody needs to build the helpfilepages and examples. Jos Skysnake and Danp2 2 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...
Developers Jos Posted October 1, 2018 Developers Share Posted October 1, 2018 Made another upload available adding Json_ObjGetItems(), Tidied source and fixed au3check warnings. Also updated json-test.au3 a bit. Thanks,Jos argumentum 1 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...
DerPensionist Posted October 28, 2018 Share Posted October 28, 2018 Please provide changes in JSON(2018.10.01b).zip Member JSON.au3 Line 512 old: Quote Local $sObjPath = $ObjPath Line 512 new Quote Local §Value, $sObjPath = $ObjPath or add "Local" to Line 515 to avoid Message: Quote C:\Program Files (x86)\AutoIt3\Include_User\JSON.au3" (515) : ==> Variable used without being declared.: ======================================== Member Json_Test.au3 . to prettify Lines 29 & 30 are part of "Test2", change "Test3" to "Test2" thx Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2018 Developers Share Posted October 28, 2018 (edited) 1 hour ago, DerPensionist said: Quote Local §Value, $sObjPath = $ObjPath I guess you mean an $ sign there in stead of the § Will add that for avoiding the au3check warning and update the zipfile. Thanks,Jos Edited October 28, 2018 by 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...
satanico64 Posted October 29, 2018 Share Posted October 29, 2018 (edited) hi guys, It's a been a long time since i use to pass json as parameter to my functions, really cool to add new parameter without changing code that much. Each time i use the same variable $jsonfunc, so in many function i do: If Json_IsObject($jsonfunc) Then Json_ObjClear($jsonfunc) Else $jsonfunc = Json_ObjCreate() EndIf and next, i add parameter and all is ok, i call my functions with $jsonfunc as parameter And this is ok. Today i encounter a really simple problem, that you can reproduce with the code below: I just pass a json (jsonfunc) as a parameter to myfunc(), in the function, the parameter is $jsonparam. But if i do Json_ObjClear($jsonfunc) My $jsonparam is cleared. why ?? #include <Json.au3> local $jsonfunc Func myfunc($jsonparam) ConsoleWrite("we're in myfunc" & @CRLF) If Not Json_IsObject($jsonparam) Then ConsoleWrite("$jsonparam is not an object, leaving." & @CRLF) Return Else ConsoleWrite("$jsonparam is an object OK." & @CRLF) EndIf If Json_IsObject($jsonfunc) Then ConsoleWrite("$jsonparam, before clear the $jsonfunc:" & @CRLF & Json_Encode($jsonparam, $Json_PRETTY_PRINT) & @CRLF & @CRLF) Json_ObjClear($jsonfunc) ConsoleWrite("$jsonparam, after clear the $jsonfunc:" & @CRLF & Json_Encode($jsonparam, $Json_PRETTY_PRINT) & @CRLF) Else $jsonfunc = Json_ObjCreate() EndIf EndFunc If Json_IsObject($jsonfunc) Then Json_ObjClear($jsonfunc) Else $jsonfunc = Json_ObjCreate() EndIf Json_ObjPut($jsonfunc, "TRI", "1_Niveau_") Json_ObjPut($jsonfunc, "JSON_ORIGINEL", 1) ConsoleWrite("we call function with a json ($jsonfunc) as parameter" & @CRLF) myfunc($jsonfunc) Spoiler Output: we call function with a json ($jsonfunc) as parameter we're in myfunc $jsonparam is an object OK. $jsonparam, before clear the $jsonfunc: { "TRI": "1_Niveau_", "JSON_ORIGINEL": 1 } $jsonparam, after clear the $jsonfunc: {} any idea ? thanks. Nicolas. Edit: it is the same with last version of Json from 2018/10/28 and one from more than a year. Edited October 29, 2018 by satanico64 Link to comment Share on other sites More sharing options...
TheXman Posted October 29, 2018 Share Posted October 29, 2018 (edited) @satanico64 You appear to have a problem with the scope of the $jsonfunc variable. What happens when you run the snippet below? It works for me. All I did was change the "Local" to "Global" #include <myincludes\json\Json.au3> global $jsonfunc Func myfunc($jsonparam) ConsoleWrite("we're in myfunc" & @CRLF) If Not Json_IsObject($jsonparam) Then ConsoleWrite("$jsonparam is not an object, leaving." & @CRLF) Return Else ConsoleWrite("$jsonparam is an object OK." & @CRLF) EndIf If Json_IsObject($jsonfunc) Then ConsoleWrite("$jsonparam, before clear the $jsonfunc:" & @CRLF & Json_Encode($jsonparam, $Json_PRETTY_PRINT) & @CRLF & @CRLF) Json_ObjClear($jsonfunc) ConsoleWrite("$jsonparam, after clear the $jsonfunc:" & @CRLF & Json_Encode($jsonparam, $Json_PRETTY_PRINT) & @CRLF) Else $jsonfunc = Json_ObjCreate() EndIf EndFunc If Json_IsObject($jsonfunc) Then Json_ObjClear($jsonfunc) Else $jsonfunc = Json_ObjCreate() EndIf Json_ObjPut($jsonfunc, "TRI", "1_Niveau_") Json_ObjPut($jsonfunc, "JSON_ORIGINEL", 1) ConsoleWrite("we call function with a json ($jsonfunc) as parameter" & @CRLF) myfunc($jsonfunc) Result: we call function with a json ($jsonfunc) as parameter we're in myfunc $jsonparam is an object OK. $jsonparam, before clear the $jsonfunc: { "TRI": "1_Niveau_", "JSON_ORIGINEL": 1 } $jsonparam, after clear the $jsonfunc: {} Edited October 29, 2018 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...
satanico64 Posted October 29, 2018 Share Posted October 29, 2018 I thought about the scope too, and tried that before, it does'not change anything. Sames conclusions for you ? Meanwhile, there is none reason to reset my function parameter, without calling it explicitely Link to comment Share on other sites More sharing options...
TheXman Posted October 29, 2018 Share Posted October 29, 2018 I added my result to my post. As I said, it worked for me. Did you run the exact snippet or some other code? 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...
satanico64 Posted October 29, 2018 Share Posted October 29, 2018 in your result, the json is cleared too after the objclear Quote $jsonparam, after clear the $jsonfunc: {} Link to comment Share on other sites More sharing options...
TheXman Posted October 29, 2018 Share Posted October 29, 2018 What result are you expecting after the json_objclear()? 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...
satanico64 Posted October 29, 2018 Share Posted October 29, 2018 I clear a json which name is $jsonfunc, because i want to use it later. I clearly do not expect that my other json $jsonparam to be cleared. Link to comment Share on other sites More sharing options...
TheXman Posted October 29, 2018 Share Posted October 29, 2018 Oh, okay, I see what you are saying now. Let me take a closer look. 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 October 29, 2018 Share Posted October 29, 2018 I'm not exactly sure how AutoIt works in this regard without testing it, but in other languages, objects are passed ByRef. Therefore, if the same holds true you aren't using a copy of the $jsonfunc object in myfunc(), you are using/manipulating the object itself. 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...
Developers Jos Posted October 29, 2018 Developers Share Posted October 29, 2018 Pretty sure you are passing a PTR so both variables are using the same pointer hence use the same memory space. 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...
satanico64 Posted October 29, 2018 Share Posted October 29, 2018 i thought about that too, it would mean that a variable passed as a parameter would be a by ref ? no, i don't think so ! In a function, the scope of a parameter is local scope. But i agree that the problem is something like that, Pretty sure it's a PTR problem, but what should i do with that ? except using another name ... Link to comment Share on other sites More sharing options...
TheXman Posted October 29, 2018 Share Posted October 29, 2018 (edited) Passing something ByRef means that you are passing a pointer. Edited October 29, 2018 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...
Developers Jos Posted October 29, 2018 Developers Share Posted October 29, 2018 Byref is a mute point as it passes a pointer. 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...
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