user8622254
user8622254

Reputation:

Node.js work with (JSON String / Arr?)

I am working on a project running on node.js, but I have never worked with JSON before. I included an API, run a function and got a result returned. When I console.log the result I get this:

{ 'Sealed Graffiti | GLHF (Bazooka Pink)': {
    opskins_price: 2,
    market_price: 3,
    opskins_lowest_price: 2
  }
}

How do I work with that result? For example access the opskins_price.

Upvotes: 1

Views: 74

Answers (1)

Michael
Michael

Reputation: 11914

var obj = {
    'Sealed Graffiti | GLHF (Bazooka Pink)': {
        opskins_price: 2,
        market_price: 3,
        opskins_lowest_price: 2
    }
}

console.log(obj['Sealed Graffiti | GLHF (Bazooka Pink)'].opskins_price) // output: 2

Upvotes: 1

Related Questions