Jump to content
Sign in to follow this  
BinaryBrother

JSON, I hate it.

Recommended Posts

BinaryBrother

I'm having as much trouble figuring out how JSON works as I did learning a little SQL.

I've tried 4 of the different JSON UDFs around the forums, and I'm on day 3 of trying to figure this out myself... I'm actually beginning to worry that my JSON data is bad.

I tried messing with associative arrays.
/?do=embed' frameborder='0' data-embedContent>>

An old[er]? JSON UDF:
/?do=embed#entry1111352'' frameborder='0' data-embedContent>>

A new RFC compliant one:
'?do=embed' frameborder='0' data-embedContent>>

and the "non-strict" one:

 

I'm building a Google Voice UDF for AutoIt and found out how to get JSON return values for everything I need, which I've heard is what I want.

Could someone just show me a quick example of iterating through the different JSON values?

I was able to get the RFC compliant one to spit out a little info, which had me hopeful, but still stumped.

$t = FileRead("C:\Users\Owner\Downloads\download.xml")
$test = _JSONDecodeall($t)
_ArrayDisplay($test[0])

$test1 =  _JSONDecode($t, 'messages')
$test2 =  _JSONDecode($t, 'JSON_unpack')
_ArrayDisplay($test1)
_ArrayDisplay($test2)

You can grab your own JSON examples from here.
http://google.com/voice/request/messages

If an old or trusted member, MVP, or that bum trancexx, needs my JSON output, I'll PM it.  o:)  :whistle: 
 

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
trancexx

If I want to get swf player location from the downloaded file I run this:

#include "JSMN.au3"
    
$sPlayer = Jsmn_ObjGet(Jsmn_Decode(FileRead("C:\Users\Owner\Downloads\download.xml")), "swfPlayer")
    
ConsoleWrite($sPlayer & @CRLF)
... and get:

/voice/resources/532502447-audioPlayer.swf
Is that wrong? Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
BinaryBrother

Thanks for your helpful reply, trancexx.
 

Using your example, I get the same output as you. However, when I try to get "messages", "messageList", "id", or anything else, it just returns blank. I'm so lost in this JSON abyss.

Edit:
I just discovered a resource that, I believe, will greatly help me in this project. It has allowed me to visualize JSON data and its structure.

Resource: http://jsonviewer.stack.hu/

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
trancexx

If it's blank then it's blank, empty, none, false, null. That's also valid result.

For "r" I get hEmccRP60m9YRRfUdF6uXRMKOKk=, for "resultsPerPage" I get 5, etc...


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
BinaryBrother

Ultimately, I'm trying to access the actual message text and relevant information, ex; Who texted me and from which number. That information is in the JSON data.

I believe I am after the array of information inside "messageList".
http://screencast.com/t/LQlwFbIYJ

$test = Jsmn_Decode(FileRead("C:\Users\Owner\Downloads\messages"))
$sPlayer = Jsmn_ObjGet($test, "messageList")
_ArrayDisplay($sPlayer)

This gives me an empty $array[5], but it is correctly sized to fit the data.  :doh: 

I'm a lot closer now, though. I wasn't getting any values, before.

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
trancexx

I see you no longer require MVP status for the member with whom you would share json file with. I'm also not old and not even trusted by some. Hm. What now?

Send me your file.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
trancexx

Of course I trust you, trancexx. That's actually why I changed it from MVP, because of your status not being MVP.  :P

Oh, then it's MVP member, old member, trusted member or trancexx. :D

Okly dokly. That's fine.

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
BinaryBrother

trancexx has provided me everything that I need for figuring out the rest. As soon as I'm done with this UDF, I'll post it in the examples section.

Many thanks, trancexx.

Of course, it didn't help when most other JSON documentation says that JSON key/value pairs are normally accessed like,

$Array = $JSON.MessagesArray
$Var = $Object.Username

Or

$Username = $JSON.Key("Username")

But the method seems to be a bit different with AutoIt.

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×