RESTRequest und JSON-Abfrage



  • Hallo!

    Ich bin aktuell dabei mit der REST-Schnittstelle eine JSON-Abfrage zu machen. Dies klappt soweit auch, will heißen die Ergebnisse der Abfrage tauchen in meinem StringGrid auf. Was mich allerdings irritiert ist die Tatsache, dass das komplette Ergebnis der Abfrage in einer einzigen Zeile erscheint, es werden keinerlei Spalten getrennt, die einzige Trennung innerhalb der Ergebnis erfolgt durch ein Komma.

    Weiter ist mir auch nicht klar, wie ich Werte aus der Verschachtelung abfragen kann.

    Hier noch ein Beispiel wie die Abfrage im RESTDebugger aussieht:

    [
        {
            "id": 1,
            "name": "Bitcoin",
            "symbol": "BTC",
            "slug": "bitcoin",
            "num_market_pairs": 8494,
            "date_added": "2013-04-28T00:00:00.000Z",
            "tags": [
                "mineable",
                "pow",
                "sha-256",
                "store-of-value",
                "state-channels",
                "coinbase-ventures-portfolio",
                "three-arrows-capital-portfolio",
                "polychain-capital-portfolio",
                "binance-labs-portfolio",
                "arrington-xrp-capital",
                "blockchain-capital-portfolio",
                "boostvc-portfolio",
                "cms-holdings-portfolio",
                "dcg-portfolio",
                "dragonfly-capital-portfolio",
                "electric-capital-portfolio",
                "fabric-ventures-portfolio",
                "framework-ventures",
                "galaxy-digital-portfolio",
                "huobi-capital",
                "alameda-research-portfolio",
                "a16z-portfolio",
                "1confirmation-portfolio",
                "winklevoss-capital",
                "usv-portfolio",
                "placeholder-ventures-portfolio",
                "pantera-capital-portfolio",
                "multicoin-capital-portfolio",
                "paradigm-xzy-screener"
            ],
            "max_supply": 21000000,
            "circulating_supply": 18861706,
            "total_supply": 18861706,
            "platform": null,
            "cmc_rank": 1,
            "last_updated": "2021-11-02T16:01:02.000Z",
            "quote": {
                "USD": {
                    "price": 64201.821135057944,
                    "volume_24h": 36004282262.9272,
                    "volume_change_24h": -1.5896,
                    "percent_change_1h": 1.28672006,
                    "percent_change_24h": 4.24542105,
                    "percent_change_7d": 2.62137062,
                    "percent_change_30d": 33.95382919,
                    "percent_change_60d": 26.89875146,
                    "percent_change_90d": 63.28092595,
                    "market_cap": 1210955874914.0493,
                    "market_cap_dominance": 44.1201,
                    "fully_diluted_market_cap": 1348238243836.22,
                    "last_updated": "2021-11-02T16:01:02.000Z"
                }
            }
        },
        {
            "id": 1027,
            "name": "Ethereum",
            "symbol": "ETH",
            "slug": "ethereum",
            "num_market_pairs": 4648,
            "date_added": "2015-08-07T00:00:00.000Z",
            "tags": [
                "mineable",
                "pow",
                "smart-contracts",
                "ethereum",
                "binance-smart-chain",
                "coinbase-ventures-portfolio",
                "three-arrows-capital-portfolio",
                "polychain-capital-portfolio",
                "binance-labs-portfolio",
                "arrington-xrp-capital",
                "blockchain-capital-portfolio",
                "boostvc-portfolio",
                "cms-holdings-portfolio",
                "dcg-portfolio",
                "dragonfly-capital-portfolio",
                "electric-capital-portfolio",
                "fabric-ventures-portfolio",
                "framework-ventures",
                "hashkey-capital-portfolio",
                "kinetic-capital",
                "huobi-capital",
                "alameda-research-portfolio",
                "a16z-portfolio",
                "1confirmation-portfolio",
                "winklevoss-capital",
                "usv-portfolio",
                "placeholder-ventures-portfolio",
                "pantera-capital-portfolio",
                "multicoin-capital-portfolio",
                "paradigm-xzy-screener"
            ],
            "max_supply": null,
            "circulating_supply": 118178745.249,
            "total_supply": 118178745.249,
            "platform": null,
            "cmc_rank": 2,
            "last_updated": "2021-11-02T16:01:02.000Z",
            "quote": {
                "USD": {
                    "price": 4519.017229138407,
                    "volume_24h": 19075915405.49936,
                    "volume_change_24h": 6.7711,
                    "percent_change_1h": 0.9778521,
                    "percent_change_24h": 3.85024773,
                    "percent_change_7d": 7.86142455,
                    "percent_change_30d": 32.36790724,
                    "percent_change_60d": 13.74847824,
                    "percent_change_90d": 68.59015722,
                    "market_cap": 534051785898.18964,
                    "market_cap_dominance": 19.4581,
                    "fully_diluted_market_cap": 534051785898.19,
                    "last_updated": "2021-11-02T16:01:02.000Z"
                }
            }
        },
        {
            "id": 1839,
            "name": "Binance Coin",
            "symbol": "BNB",
            "slug": "binance-coin",
            "num_market_pairs": 545,
            "date_added": "2017-07-25T00:00:00.000Z",
            "tags": [
                "marketplace",
                "centralized-exchange",
                "payments",
                "binance-smart-chain",
                "alameda-research-portfolio",
                "multicoin-capital-portfolio"
            ],
            "max_supply": 166801148,
            "circulating_supply": 166801148,
            "total_supply": 166801148,
            "platform": null,
            "cmc_rank": 3,
            "last_updated": "2021-11-02T16:01:08.000Z",
            "quote": {
                "USD": {
                    "price": 562.3588765327808,
                    "volume_24h": 2579198024.283231,
                    "volume_change_24h": 18.0152,
                    "percent_change_1h": 0.86710435,
                    "percent_change_24h": 4.47760142,
                    "percent_change_7d": 16.40882501,
                    "percent_change_30d": 31.57513796,
                    "percent_change_60d": 13.9743951,
                    "percent_change_90d": 69.15753887,
                    "market_cap": 93802106193.6581,
                    "market_cap_dominance": 3.4165,
                    "fully_diluted_market_cap": 93802106193.66,
                    "last_updated": "2021-11-02T16:01:08.000Z"
                }
            }
        },
        {
            "id": 825,
            "name": "Tether",
            "symbol": "USDT",
            "slug": "tether",
            "num_market_pairs": 19044,
            "date_added": "2015-02-25T00:00:00.000Z",
            "tags": [
                "payments",
                "stablecoin",
                "stablecoin-asset-backed",
                "binance-smart-chain",
                "avalanche-ecosystem",
                "solana-ecosystem"
            ],
            "max_supply": null,
            "circulating_supply": 70545760760.65137,
            "total_supply": 71357845272.48163,
            "platform": {
                "id": 1027,
                "name": "Ethereum",
                "symbol": "ETH",
                "slug": "ethereum",
                "token_address": "0xdac17f958d2ee523a2206206994597c13d831ec7"
            },
            "cmc_rank": 4,
            "last_updated": "2021-11-02T16:00:19.000Z",
            "quote": {
                "USD": {
                    "price": 1.00106384500277,
                    "volume_24h": 118312371169.18582,
                    "volume_change_24h": 31.7157,
                    "percent_change_1h": 0.02372082,
                    "percent_change_24h": -0.0084427,
                    "percent_change_7d": 0.08089799,
                    "percent_change_30d": 0.10829297,
                    "percent_change_60d": 0.07293925,
                    "percent_change_90d": 0.0931011,
                    "market_cap": 70620810515.7032,
                    "market_cap_dominance": 2.5722,
                    "fully_diluted_market_cap": 71433758959.58,
                    "last_updated": "2021-11-02T16:00:19.000Z"
                }
            }
        },
        {
            "id": 2010,
            "name": "Cardano",
            "symbol": "ADA",
            "slug": "cardano",
            "num_market_pairs": 306,
            "date_added": "2017-10-01T00:00:00.000Z",
            "tags": [
                "mineable",
                "dpos",
                "pos",
                "platform",
                "research",
                "smart-contracts",
                "staking",
                "binance-smart-chain",
                "cardano-ecosystem"
            ],
            "max_supply": 45000000000,
            "circulating_supply": 33270336757.644,
            "total_supply": 33676945631.8,
            "platform": null,
            "cmc_rank": 5,
            "last_updated": "2021-11-02T16:00:20.000Z",
            "quote": {
                "USD": {
                    "price": 1.99131031322393,
                    "volume_24h": 2532649141.932038,
                    "volume_change_24h": -3.1108,
                    "percent_change_1h": 0.75250667,
                    "percent_change_24h": 1.01693617,
                    "percent_change_7d": -7.91819884,
                    "percent_change_30d": -12.2580443,
                    "percent_change_60d": -33.82485314,
                    "percent_change_90d": 45.60299679,
                    "market_cap": 66251564709.92971,
                    "market_cap_dominance": 2.4138,
                    "fully_diluted_market_cap": 89608964095.08,
                    "last_updated": "2021-11-02T16:00:20.000Z"
                }
            }
        },
        {
            "id": 5426,
            "name": "Solana",
            "symbol": "SOL",
            "slug": "solana",
            "num_market_pairs": 176,
            "date_added": "2020-04-10T00:00:00.000Z",
            "tags": [
                "pos",
                "platform",
                "solana-ecosystem",
                "cms-holdings-portfolio",
                "kinetic-capital",
                "alameda-research-portfolio",
                "multicoin-capital-portfolio"
            ],
            "max_supply": null,
            "circulating_supply": 300937910.3573377,
            "total_supply": 507977519.3894084,
            "platform": null,
            "cmc_rank": 6,
            "last_updated": "2021-11-02T16:01:04.000Z",
            "quote": {
                "USD": {
                    "price": 209.57128825839067,
                    "volume_24h": 2028123998.9307761,
                    "volume_change_24h": -38.9554,
                    "percent_change_1h": 2.35711059,
                    "percent_change_24h": 2.71913217,
                    "percent_change_7d": 1.30377283,
                    "percent_change_30d": 21.18754552,
                    "percent_change_60d": 49.73792029,
                    "percent_change_90d": 491.10974455,
                    "market_cap": 63067945559.37535,
                    "market_cap_dominance": 2.2971,
                    "fully_diluted_market_cap": 106457503144.74,
                    "last_updated": "2021-11-02T16:01:04.000Z"
                }
            }
        },
        {
            "id": 52,
            "name": "XRP",
            "symbol": "XRP",
            "slug": "xrp",
            "num_market_pairs": 641,
            "date_added": "2013-08-04T00:00:00.000Z",
            "tags": [
                "medium-of-exchange",
                "enterprise-solutions",
                "binance-chain",
                "arrington-xrp-capital",
                "galaxy-digital-portfolio",
                "a16z-portfolio",
                "pantera-capital-portfolio"
            ],
            "max_supply": 100000000000,
            "circulating_supply": 47015237181,
            "total_supply": 99990181120,
            "platform": null,
            "cmc_rank": 7,
            "last_updated": "2021-11-02T16:01:03.000Z",
            "quote": {
                "USD": {
                    "price": 1.12370876952241,
                    "volume_24h": 3234791357.3876834,
                    "volume_change_24h": -16.971,
                    "percent_change_1h": 1.04039947,
                    "percent_change_24h": 2.75036228,
                    "percent_change_7d": 1.32079875,
                    "percent_change_30d": 5.62862629,
                    "percent_change_60d": -13.86190881,
                    "percent_change_90d": 54.49901553,
                    "market_cap": 52831434321.46577,
                    "market_cap_dominance": 1.9249,
                    "fully_diluted_market_cap": 112370876952.24,
                    "last_updated": "2021-11-02T16:01:03.000Z"
                }
            }
        },
        {
            "id": 6636,
            "name": "Polkadot",
            "symbol": "DOT",
            "slug": "polkadot-new",
            "num_market_pairs": 242,
            "date_added": "2020-08-19T00:00:00.000Z",
            "tags": [
                "substrate",
                "polkadot",
                "binance-chain",
                "binance-smart-chain",
                "polkadot-ecosystem",
                "three-arrows-capital-portfolio",
                "polychain-capital-portfolio",
                "blockchain-capital-portfolio",
                "boostvc-portfolio",
                "cms-holdings-portfolio",
                "coinfund-portfolio",
                "fabric-ventures-portfolio",
                "fenbushi-capital-portfolio",
                "hashkey-capital-portfolio",
                "kinetic-capital",
                "1confirmation-portfolio",
                "placeholder-ventures-portfolio",
                "pantera-capital-portfolio",
                "exnetwork-capital-portfolio"
            ],
            "max_supply": null,
            "circulating_supply": 987579314.957085,
            "total_supply": 1103303471.382273,
            "platform": null,
            "cmc_rank": 8,
            "last_updated": "2021-11-02T16:01:05.000Z",
            "quote": {
                "USD": {
                    "price": 51.56151893785108,
                    "volume_24h": 4714538849.928753,
                    "volume_change_24h": 66.2418,
                    "percent_change_1h": 1.01953593,
                    "percent_change_24h": 5.81657669,
                    "percent_change_7d": 17.5085193,
                    "percent_change_30d": 61.18079257,
                    "percent_change_60d": 56.81372692,
                    "percent_change_90d": 173.06658602,
                    "market_cap": 50921089550.78974,
                    "market_cap_dominance": 1.8553,
                    "fully_diluted_market_cap": 56888002833.87,
                    "last_updated": "2021-11-02T16:01:05.000Z"
                }
            }
        },
        {
            "id": 5994,
            "name": "SHIBA INU",
            "symbol": "SHIB",
            "slug": "shiba-inu",
            "num_market_pairs": 155,
            "date_added": "2020-08-01T00:00:00.000Z",
            "tags": [
                "memes",
                "doggone-doggerel"
            ],
            "max_supply": null,
            "circulating_supply": 549095509738353,
            "total_supply": 589738956207003.8,
            "platform": {
                "id": 1027,
                "name": "Ethereum",
                "symbol": "ETH",
                "slug": "ethereum",
                "token_address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce"
            },
            "cmc_rank": 9,
            "last_updated": "2021-11-02T16:01:08.000Z",
            "quote": {
                "USD": {
                    "price": 0.00006803185906,
                    "volume_24h": 4517196328.859606,
                    "volume_change_24h": -49.8663,
                    "percent_change_1h": -1.92391835,
                    "percent_change_24h": -4.26165537,
                    "percent_change_7d": 42.90992945,
                    "percent_change_30d": 748.46784941,
                    "percent_change_60d": 845.82948324,
                    "percent_change_90d": 990.16973325,
                    "market_cap": 37355988328.99849,
                    "market_cap_dominance": 1.3611,
                    "fully_diluted_market_cap": 40121037547.99,
                    "last_updated": "2021-11-02T16:01:08.000Z"
                }
            }
        },
        {
            "id": 74,
            "name": "Dogecoin",
            "symbol": "DOGE",
            "slug": "dogecoin",
            "num_market_pairs": 398,
            "date_added": "2013-12-15T00:00:00.000Z",
            "tags": [
                "mineable",
                "pow",
                "scrypt",
                "medium-of-exchange",
                "memes",
                "payments",
                "binance-smart-chain",
                "doggone-doggerel"
            ],
            "max_supply": null,
            "circulating_supply": 131943568830.3418,
            "total_supply": 131943568830.3418,
            "platform": null,
            "cmc_rank": 10,
            "last_updated": "2021-11-02T16:01:03.000Z",
            "quote": {
                "USD": {
                    "price": 0.27327198855036,
                    "volume_24h": 2208010433.481001,
                    "volume_change_24h": -46.1706,
                    "percent_change_1h": -0.27264837,
                    "percent_change_24h": 1.20108432,
                    "percent_change_7d": 2.50442808,
                    "percent_change_30d": 24.02606517,
                    "percent_change_60d": -9.40092463,
                    "percent_change_90d": 36.38296006,
                    "market_cap": 36056481430.6988,
                    "market_cap_dominance": 1.3137,
                    "fully_diluted_market_cap": 36056481430.7,
                    "last_updated": "2021-11-02T16:01:03.000Z"
                }
            }
        }
    ]```cpp
    
    Muss ich innerhalb des StringGrid oder an anderer Stelle noch etwas einstellen damit die Trennung in einzelne Spalten erfolgt?
    
    Ich hoffe ich konnte mich verständlich ausdrücken.
    
    Ach ja, ich verwende C++ Builder 11.0
    
    Viele Grüße
    
    -pianoman-


  • Du musst das JSON schon parsen und in eine für das Grid passende form bringen.
    Und das empfangene JSON ist in einer Zeile -> der json string ist nicht "pretty" formatiert.

    Der RESTDebugger zeigt das Json "pretty" formartiert an.



  • Hallo und erstmal danke für die Antwort, damit hatte ich so nicht gerechnet.

    Hast Du noch ein Stichwort für mich im Hinblick auf das parsen?

    Muss ich es wirklich händisch programmieren oder gibt es dafür auch eine Komponente?

    Habe dazu bislang relativ wenig gefunden.

    Danke und viele Grüße

    -pianoman-



  • Eine der bekanntesten Komponenten dafür ist JSON for Modern C++.

    Beim RAD Studio gibt es aber auch schon Support-Klassen dafür: JSON / JSON Frameworks


Anmelden zum Antworten