Hallo, ich brauch mal eure Hilfe und zwar möchte ich den Inhalt einer API in einer json Datei speichern, das klappt auch soweit super, doch ist mir der Inhalt der Json Datei zu viel.
Api auslesen und in Json speichen via fs.writeFileSync:
Snippet aus der erzeugten prices.json Datei:
Dies Ausgabe ist mir zu viel. Wie bekomme ich es hin, das die json Datei nur noch folgendes beinhaltet:
Also quasi nur noch alle
"market_hash_name": price
In diesem Format in der json speichert?
MfG
Api auslesen und in Json speichen via fs.writeFileSync:
Javascript:
function getPriceList() {
request(priceUrl, (error, response, body) => {
if (error || response.statusCode !== 200) return console.log(`Error: ${error} - Status Code: ${response.statusCode}`);
//console.log("DEBUG: " + body);
fs.writeFileSync("prices.json", JSON.stringify(JSON.parse(body), null, 2));
});
}
getPriceList();
Snippet aus der erzeugten prices.json Datei:
Javascript:
{
"status": "success",
"prices": [
{
"app_id": "730",
"context_id": "2",
"market_hash_name": "'Blueberries' Buckshot | NSWC SEAL",
"price": "1.71",
"pricing_mode": "market",
"skewness": "-0.49",
"created_at": 1631410301,
"icon_url": null,
"name_color": null,
"quality_color": null,
"rarity_color": null,
"instant_sale_price": null
},
{
"app_id": "730",
"context_id": "2",
"market_hash_name": "'The Doctor' Romanov | Sabre",
"price": "3.06",
"pricing_mode": "market",
"skewness": "-0.05",
"created_at": 1631419491,
"icon_url": null,
"name_color": null,
"quality_color": null,
"rarity_color": null,
"instant_sale_price": "1.22"
},
{
"app_id": "730",
"context_id": "2",
"market_hash_name": "'Two Times' McCoy | TACP Cavalry",
"price": "1.23",
"pricing_mode": "market",
"skewness": "-0.11",
"created_at": 1631407484,
"icon_url": null,
"name_color": null,
"quality_color": null,
"rarity_color": null,
"instant_sale_price": null
}
]
}
Dies Ausgabe ist mir zu viel. Wie bekomme ich es hin, das die json Datei nur noch folgendes beinhaltet:
Javascript:
{
"'Blueberries' Buckshot | NSWC SEAL": 1.71,
"'The Doctor' Romanov | Sabre": 3.06,
"'Two Times' McCoy | TACP Cavalry": 1.23
}
Also quasi nur noch alle
"market_hash_name": price
In diesem Format in der json speichert?
MfG