Jump to content

Recommended Posts

Posted (edited)
27 minutes ago, loulou2522 said:

Where can i  fin and downlaod  json.au3. ?

The bottom of the first post of this topic.

 

Edited by TheXman
  • 1 month later...
  • Developers
Posted

Correct as there's an issue with that latest version that I have been unable to resolve I reverted to the previous version. 
Updates the first post and change the last text with a strikethrough so it is clear, but the line above does contain the file and the reason for reverting.

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.
  :)

  • 4 weeks later...
Posted
1 minute ago, TheOne23 said:

Hi Guys,

Can someone direct me to the download path of Jason.au3 UDF download page or JSMN.au3?

 

Thanks in advance.

JasonvsFreddy.au3 ? 😄

 

For the files, see bottom of the 1st post.

  • 3 weeks later...
Posted

Hello. I have json like this 

{"response":("userid":"4798","success":1)}

Please, help me add this values to variables, I have "Error: Error in expression" :(

 

$object = json_decode($data)
$message=json_get($object,["userid"])
MsgBox("","Test",$message)

I want make like this logic: if success = 1 then popup message with "4798" (userid content), else (if success = 0) then message with "error".

Posted (edited)
23 minutes ago, auitden said:

{"response":("userid":"4798","success":1)}

Your JSON example is invalid.  Just plug it into any JSON validator on the web and you will see.  It most likely should have been something like:

{"response":{"userid":"4798","success":1}}

 

Correct your JSON and try again.

 

Use the json_dump() function to get an idea of how to reference json values using the dot-notation.

#include <MyIncludes\json\json.au3>  ;<== Change to your location

$data = '{"response":{"userid":"4798","success":1}}'

Json_Dump($data)

$object = json_decode($data)
$message=json_get($object,".response.userid")  ;using dot-notation
;~ $message=json_get($object,"[response][userid]")  ;using bracket-notation
MsgBox("","Test",$message)

Output:

+-> .response.userid  =4798
+-> .response.success  =1

 

@auitden: I updated my response with an example using your original script snippet.

Edited by TheXman
Posted (edited)
#include "Json.au3"

TestThis()
Func TestThis()
    
    Local $myJson = '{"response":{"userid":"4798","success":1}}'
    Json_Dump($myJson) ; to get what you look for
    
    Local $oTemp = Json_Decode($myJson)
    Local $my_userid = Json_ObjGet($oTemp, ".response.userid") ; use what you look for here
    Local $my_success = Json_ObjGet($oTemp, ".response.success")
    
    ConsoleWrite('- $my_userid = "' & $my_userid & '"' & @CRLF)
    ConsoleWrite('- $my_success = ' & $my_success & @CRLF)
    
EndFunc

:) 

Edited by argumentum
better code

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

All example perfect and works fine. Thank you very much!

When I use $data = _INetGetSource($URL) then $data print to msgbox looks fine, but after parsing I see blank screen. Json have utf-8. I think that is codepage problem...

Posted (edited)

_INetGetSource ( $sURL [, $bString = True] )
$sURL(The URL of the site.) eg 'http://www.autoitscript.com'
$bString[optional] If True the data is returned in string format, otherwise binary format.

$data = _INetGetSource($URL) <-- without the URL that is all the help I can give but try to ConsoleWrite('"' & $data & '"' & @CRLF) ;) 

Edit: I'd use binary and do my own bin2str conversion

Edited by argumentum
better

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
6 minutes ago, argumentum said:

_INetGetSource ( $sURL [, $bString = True] )
$sURL(The URL of the site.) eg 'http://www.autoitscript.com'
$bString[optional] If True the data is returned in string format, otherwise binary format.

$URL="http://192.168.1.50"
$data = _INetGetSource($URL , $bString = 'True')

;$data = '{"response":{"userid":"4798","success":1}}'

Json_Dump($data)
$object = json_decode($data)
$message=json_get($object,".response.userid")
MsgBox("","Test",$message)

Blank screen :(

Posted
4 minutes ago, argumentum said:

1) 192.168.1.50 is your internal IP
2) $bString = 'True' will equal false( i guess ), so use True or False.

1) it's for example, i can't share this :(

2) true or false, i already have this in console output:

"0x7B22726573706F6E7365223A7B22737465616D6964223A363536313139383939363737313336...654433"

 

  • 3 months later...
Posted

Hello!

 

I have

$super = json_get($object, '.result.items[1].name')

It's work correctly, but how i can check all items [0-1-2-3] or more ? i don't know how many? and if name = templateword then $i = i+1

 

  • Developers
Posted
2 hours ago, zer0n00b said:

but how i can check all items [0-1-2-3] or more ?

Please post an example of the data and what you like to retrieve so we understand what you are looking for. ;) 

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.
  :)

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
×
×
  • Create New...