You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解析仅含数组与嵌套数组、无属性名的JSON数据?

How to Extract the First Number from Each Entry in That SteamCardExchange JSON

Got it, let's work through this together. That API returns a JSON object where each key is a unique identifier (like a game's AppID) and the corresponding value is an array—the first element of that array is exactly the number you need.

Here's a simplified look at the JSON structure:

{
  "10": [0.05, "Counter-Strike", ...],
  "20": [0.10, "Team Fortress Classic", ...],
  "30": [0.15, "Day of Defeat", ...]
}

Core Logic (Works for Any Language)

The steps are straightforward, no fancy identifiers needed:

  1. Fetch and parse the JSON into a native object/dictionary.
  2. Iterate over all the values of this object (each value is an array).
  3. Grab the first element (index 0) from each array.

Example Code Snippets

Python

Using requests and json modules:

import json
import requests

# Fetch the API data
response = requests.get("https://www.steamcardexchange.net/api/request.php?GetBadgePrices_Guest")
# Parse JSON into a Python dictionary
badge_data = json.loads(response.text)

# Extract the first number from every entry
first_numbers = [entry[0] for entry in badge_data.values()]

# Use or print the result
print(first_numbers)

JavaScript (Browser)

Using native fetch:

fetch('https://www.steamcardexchange.net/api/request.php?GetBadgePrices_Guest')
  .then(res => res.json())
  .then(data => {
    // Pull the first element from each array value
    const firstNumbers = Object.values(data).map(entry => entry[0]);
    console.log(firstNumbers);
  })
  .catch(err => console.error('Fetch error:', err));

JavaScript (Node.js)

Using axios (install first with npm install axios):

const axios = require('axios');

axios.get('https://www.steamcardexchange.net/api/request.php?GetBadgePrices_Guest')
  .then(res => {
    const firstNumbers = Object.values(res.data).map(entry => entry[0]);
    console.log(firstNumbers);
  })
  .catch(err => console.error('Request error:', err));

The key insight here is that you don't need to worry about the keys (those random-looking identifiers) — you just care about the array values, and grabbing their first element is all it takes.

内容的提问来源于stack exchange,提问作者Zvrty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:47:11