claudiowilson / LeagueJS

A Javascript Wrapper for the League of Legends API
MIT License
170 stars 45 forks source link

Not all data being parsed(?) #25

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi, I am new with this stuff so maybe I just simply missed something, but when i use this code:

var options = {champData: 'all', version : '', locale: 'en_US', dataById : true};
LolApi.Static.getChampionById(1, options, function(err, champion) {
    if(!err) {
        console.log(champion.spells);
    }
    else if(err) {
        console.log(err);
    }
});

I receive this in my console (ill only paste a bit of it since it's rather large):

name: 'Summon: Tibbers',
19:43:44 web.1  |     description: 'Annie wills her bear Tibbers to life, dealing damage to units in the area. Tibbers can attack and also burns enemies that stand near him.',
19:43:44 web.1  |     sanitizedDescription: 'Annie wills her bear Tibbers to life, dealing damage to units in the area. Tibbers can attack and also burns enemies that stand near him.',
19:43:44 web.1  |     tooltip: 'Tibbers appears in a burst of flame dealing {{ e1 }} <span class="color99FF99">(+{{ a1 }})</span> magic damage to enemies in the target area.<br><br>For the next {{ e6 }} seconds, Tibbers chases down enemies and deals {{ e4 }}<span class="color99FF99"> (+{{ a2 }})</span> magic damage each second to nearby foes.<br><br><span class="color99FF99">Tibbers can be controlled by holding the alt key and using the right mouse button or by reactivating this ability.</span>',
19:43:44 web.1  |     sanitizedTooltip: 'Tibbers appears in a burst of flame dealing {{ e1 }} (+{{ a1 }}) magic damage to enemies in the target area. For the next {{ e6 }} seconds, Tibbers chases down enemies and deals {{ e4 }} (+{{ a2 }}) magic damage each second to nearby foes. Tibbers can be controlled by holding the alt key and using the right mouse button or by reactivating this ability.',
19:43:44 web.1  |     leveltip: { label: [Object], effect: [Object] },
19:43:44 web.1  |     image: 
19:43:44 web.1  |      { full: 'InfernalGuardian.png',
19:43:44 web.1  |        sprite: 'spell1.png',
19:43:44 web.1  |        group: 'spell',
19:43:44 web.1  |        x: 192,
19:43:44 web.1  |        y: 0,
19:43:44 web.1  |        w: 48,
19:43:44 web.1  |        h: 48 },
19:43:44 web.1  |     resource: '{{ cost }} Mana',
19:43:44 web.1  |     maxrank: 3,
19:43:44 web.1  |     cost: [ 100, 100, 100 ],
19:43:44 web.1  |     costType: 'Mana',
19:43:44 web.1  |     costBurn: '100',
19:43:44 web.1  |     cooldown: [ 120, 100, 80 ],
19:43:44 web.1  |     cooldownBurn: '120/100/80',
19:43:44 web.1  |     effect: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
19:43:44 web.1  |     effectBurn: 
19:43:44 web.1  |      [ '175/300/425',
19:43:44 web.1  |        '1200/2100/3000',
19:43:44 web.1  |        '80/105/130',
19:43:44 web.1  |        '35',
19:43:44 web.1  |        '30/50/70',
19:43:44 web.1  |        '45' ],
19:43:44 web.1  |     vars: [ [Object], [Object] ],
19:43:44 web.1  |     range: [ 600, 600, 600 ],
19:43:44 web.1  |     rangeBurn: '600',
19:43:44 web.1  |     key: 'InfernalGuardian',
19:43:44 web.1  |     altimages: [ [Object] ] } ]

So my problem is.. How do I get information out of these "Objects" to be displayed in the console?

Just to clarify, I am receiving this:

vars: [ [Object], [Object] ],

And I should receive this:

         "vars": [
            {
               "link": "spelldamage",
               "coeff": [0.8],
               "key": "a1"
            },
            {
               "link": "spelldamage",
               "coeff": [0.2],
               "key": "a2"
            }
         ],
claudiowilson commented 10 years ago

What you have is JSON. Since the JSON is too big, when it prints to the console it won't print the entire object. If you need to look at a specific sub object in the JSON Take a look at http://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json