mIRC Home    About    Download    Register    News    Help

Print Thread
Parsing JSON #249528 02/12/14 08:56 PM
Joined: Mar 2014
Posts: 42
S
Sjoepele Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Hi, for quite some time i've been trying to get the $json snippet from http://www.mircscripts.org/comments.php?cid=4407 to work.
For some reason it just wont for me so 2 questions:

Did anyone else happen to run into this issue?

and

Is anybody using another way to parse JSON formatted files?

Re: Parsing JSON [Re: Sjoepele] #249530 02/12/14 09:14 PM
Joined: Jan 2004
Posts: 1,318
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,318
Do you have $com locked?

//echo -ag $lock(com)

Can you provide code which fails reliably?

Re: Parsing JSON [Re: Loki12583] #249531 02/12/14 09:37 PM
Joined: Mar 2014
Posts: 42
S
Sjoepele Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
//echo -ag $lock(com) returns $false

And the code that's failing is actually your twitch bot code ha! I dont stream or whatever but i'm trying to help someone make a !game update command and im modifying your !topic one laugh Which works flawlessly (and i would like to thank you a lot for it!) except when it returns the 'game' from %data to chat. It will just say 'Game:' instead of 'Game: <game>'

which i would assume is an issue with the json indentifier.

Thanks for answering so quick btw!

Re: Parsing JSON [Re: Sjoepele] #249532 02/12/14 09:47 PM
Joined: Jan 2004
Posts: 1,318
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,318
Somebody else added the !game based on my !topic, I don't believe there's anything wrong with it. After it tries to send the game to the channel it deletes the json it had been reading, could you comment these lines out and inspect (provide) the files to make sure they're valid json?

Re: Parsing JSON [Re: Loki12583] #249533 02/12/14 09:56 PM
Joined: Mar 2014
Posts: 42
S
Sjoepele Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Yeah i think i read a topic about someone adding !game with your !topic but when i scrolled down i saw he was having issues so i figured i'd just do it myself.

And yes the code is fine, it creates the 'twitch.game.tick.data' text file like its supposed to, with what i would assume to be valid json inside:
Click to reveal..
{"mature":false,"status":"Nothing to see here!","display_name":"Sjoepele","game":"music","_id":30354638,"name":"sjoepele","created_at":"2012-05-07T11:52:46Z","updated_at":"2014-12-02T18:19:17Z","logo":"http://static-cdn.jtvnw.net/jtv_user_pictures/sjoepele-profile_image-68141bd02de21ea5-300x300.jpeg","banner":"http://static-cdn.jtvnw.net/jtv_user_pictures/sjoepele-channel_header_image-17b83eb06b7a8787-640x125.png","video_banner":"http://static-cdn.jtvnw.net/jtv_user_pictures/sjoepele-channel_offline_image-3f77036b277de141-640x360.png","background":null,"url":"http://www.twitch.tv/sjoepele","_links":{"self":"https://api.twitch.tv/kraken/channels/sjoepele","follows":"https://api.twitch.tv/kraken/channels/sjoepele/follows","commercial":"https://api.twitch.tv/kraken/channels/sjoepele/commercial","stream_key":"https://api.twitch.tv/kraken/channels/sjoepele/stream_key","chat":"https://api.twitch.tv/kraken/chat/sjoepele","features":"https://api.twitch.tv/kraken/channels/sjoepele/features","subscriptions":"https://api.twitch.tv/kraken/channels/sjoepele/subscriptions","editors":"https://api.twitch.tv/kraken/channels/sjoepele/editors","videos":"https://api.twitch.tv/kraken/channels/sjoepele/videos"},"teams":[]}


It just doesnt read it correctly, thats why i figured the json script must not be working for me. While i think it should be - i just loaded it like other scripts

Re: Parsing JSON [Re: Sjoepele] #249541 03/12/14 03:43 AM
Joined: Mar 2014
Posts: 42
S
Sjoepele Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Its so strange though because the json parsing won't work (properly) on
-topic.set
-topic.get
-game.set
-game.get

but it does work on twitch.token.request, because if it didnt, it wouldnt have written the token to twitch.ini.

confusing