|
lindenkron
|
lindenkron
|
If I call var %titles = $json(%url,titles) on https://eu.battle.net/api/wow/character/stormscale/bookmark?fields=pvp,titles shouldn't that return the value(amount) of the list "titles"? I get this to 41 lines. "titles":[
{"id":28,"name":"High Warlord %s"},
{"id":44,"name":"Rival %s"},
{"id":45,"name":"Challenger %s"},
{"id":47,"name":"Conqueror %s"},
{"id":63,"name":"%s of the Shattered Sun"},
{"id":78,"name":"%s the Explorer"},
{"id":79,"name":"%s the Diplomat"},
{"id":82,"name":"Arena Master %s"},
{"id":121,"name":"Twilight Vanquisher %s"},
{"id":124,"name":"%s the Hallowed"},
{"id":127,"name":"%s of the Horde"},
{"id":129,"name":"%s, Champion of the Frozen Wastes"},
{"id":130,"name":"Ambassador %s"},
{"id":140,"name":"%s of the Nightfall"},
{"id":143,"name":"%s Jenkins"},
{"id":155,"name":"%s the Noble"},
{"id":172,"name":"%s the Patient"},
{"id":173,"name":"%s the Light of Dawn"},
{"id":175,"name":"%s the Kingslayer"},
{"id":176,"name":"%s of the Ashen Verdict"},
{"id":259,"name":"Warbringer %s"},
{"id":194,"name":"%s, Veteran of the Horde"},
{"id":209,"name":"Scout %s"},{"id":210,"name":"Grunt %s"},
{"id":211,"name":"Sergeant %s"},
{"id":212,"name":"Senior Sergeant %s"},
{"id":213,"name":"First Sergeant %s"},
{"id":214,"name":"Stone Guard %s"},
{"id":215,"name":"Blood Guard %s"},
{"id":216,"name":"Legionnaire %s"},
{"id":217,"name":"Centurion %s"},
{"id":218,"name":"Champion %s"},
{"id":219,"name":"Lieutenant General %s"},
{"id":220,"name":"General %s"},
{"id":221,"name":"Warlord %s"},
{"id":222,"name":"High Warlord %s"},
{"id":224,"name":"%s, Hero of the Horde","selected":true},
{"id":225,"name":"%s, the Bloodthirsty"},
{"id":227,"name":"%s, Defender of a Shattered World"},
{"id":287,"name":"%s, Destroyer's End"},
{"id":314,"name":"%s the Undaunted"},
{"id":333,"name":"Brawler %s"}],
I'm not sure why it returns the value "48835248". Edit: So just learned that this number is continuously increasing - now it's "49170944", and higher every time I check it. If anyone have some clarity on this I'd appreciate it.
Last edited by lindenkron; 24/11/13 01:35 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
That's probably a pointer of some kind, if you want the length of the array, specify 0 as the index: $json(%url,titles,0)
Last edited by Loki12583; 24/11/13 03:28 PM.
|
|
|
|
lindenkron
|
lindenkron
|
That's probably a pointer of some kind, if you want the length of the array, specify 0 as the index: $json(%url,titles,0) Still returns these sort of numbers 49273312 with
var %titles = $json(%url,titles,0)
$msg($chan,%titles)
Last edited by lindenkron; 24/11/13 05:20 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
My bad, you actually need to use the count property: $json(%url,titles).count
|
|
|
|
lindenkron
|
lindenkron
|
My bad, you actually need to use the count property: $json(%url,titles).count Sweet. I would've never gotten that. Can you elaborate on why .count does that - and what it is?  Also little side question if you're not too busy, the script mentioned in another thread were replied in http://www.mircscripts.org/comments.php?cid=4407 doesn't interpret æøå so when ever you try to do an API call on a URL with æøå in it, it returns as false. Example: "https://eu.battle.net/api/wow/character/Outland/Livb%C3%A5ten?fields=pvp,titles" calling that gives "false".
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
It works with .count because that's how the script works. Read the help provided with the script. //var %url = https://eu.battle.net/api/wow/character/Outland/Livb%C3%A5ten?fields=pvp,titles | echo -ag $json(%url, name) This works perfectly fine.
|
|
|
|
lindenkron
|
lindenkron
|
It works with .count because that's how the script works. Read the help provided with the script. //var %url = https://eu.battle.net/api/wow/character/Outland/Livb%C3%A5ten?fields=pvp,titles | echo -ag $json(%url, name) This works perfectly fine. I've read the Syntax and Examples part of the help for json countless amounts of times just to understand the basics of how to use it (lol), I see that there's ".count" after but I never understood why that was. I guess it's just one of those things that I don't need to understand  Maybe the link I provided works (Livb%C3%A5ten) because I copy pasted that. If I type in any name (tested) with æøå and do an API pull with it it gives an unable to retrieve information error. Works with any non-æøå name though. Something is going wrong in translation somewhere. Typing: https://eu.battle.net/api/wow/character/Outland/Livbåten?fields=pvp,titles Typing that in URL gives results, but doing !rating Livbåten Outland eu does not work. (Also when copy pasting this URL I get https://eu.battle.net/api/wow/character/Outland/Livb%C3%A5ten?fields=pvp,titles) for some reason. Is the JSON not parsing it as UTF-8 or something. I'm unsure as to why it doesn't work. Any suggestion for trouble shooting. I'm at a loss. <3
|
|
|
|
Joined: Jan 2004
Posts: 1,330
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,330 |
You need to url encode the text to escape invalid characters: $urlencode(Livbåten) will return Livb%C3%A5ten alias urlencode return $regsubex($1-,/([^A-Z0-9])/gi,$+(%,$base($asc(\1),10,16)))
|
|
|
|
lindenkron
|
lindenkron
|
You need to url encode the text to escape invalid characters: $urlencode(Livbåten) will return Livb%C3%A5ten alias urlencode return $regsubex($1-,/([^A-Z0-9])/gi,$+(%,$base($asc(\1),10,16))) That worked brilliantly. Thx Lokisan.
|
|
|
|
Deega
|
Deega
|
Check your json script, under the heading Syntax. $json.enc(<URL>) Encodes a URL. Uses JavaScript's encodeURI().
|
|
|
|
lindenkron
|
lindenkron
|
Check your json script, under the heading Syntax. $json.enc(<URL>) Encodes a URL. Uses JavaScript's encodeURI(). Yes, I see it there but with my knowledge poll it's quite limited what that tells me. Or what it does/how to use it properly Edit: Of cause I understand it now that Loki explained it etc, but thanks for pointing it out that it was there all along :P.
Last edited by lindenkron; 25/11/13 01:47 AM.
|
|
|
|
|