Chase
Chase

Reputation: 3

How to pull a specific piece of json from an array

I am currently using an API for steam prices and I am wondering how I can pull one specific piece of this file for example:

{"60's Army Jacket":"4.49","Addicted Guitarist":"3.13","Agony Yellow":"0.92","Aircraft Parts AK47":"0.89",

Just the prices of the item and not the market name, I am very new to this so I don't know for sure I tried a different method but I got lost and it was not working as planned so if I can be provided with resources or assistance that would be great <3.

Upvotes: 0

Views: 42

Answers (1)

Daniel Tran
Daniel Tran

Reputation: 6171

Here you go:

const data = ({"60's Army Jacket":"4.49","Addicted Guitarist":"3.13","Agony Yellow":"0.92","Aircraft Parts AK47":"0.89"});
var extractedData = [];

for (const item in data) {
   if (data.hasOwnProperty(item)) {
       extractedData.push(data[item]);
   }
}

console.log(extractedData);

Updated from comment:

const extractedValue = Object.values(data);

Upvotes: 2

Related Questions