Currently, I am writing a C# wrapper for an API. It however, takes a currency, USD, GBP etc and converts data for the provided currency. When doing this, it also changes the name of some of the returned JSON values.
price_eur
price_usd
etc for example.
So my question would be, how can I work with this instead of writing hundreds of different classes for a couple of naming differences? I dont think a JsonProperty could fix this as the property needs to be a constant and that is about as far as my experience goes.
JSON to show how it differs:
Euro:
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "5648.67",
"price_btc": "1.0",
"24h_volume_usd": "1847890000.0",
"market_cap_usd": "93932015864.0",
"available_supply": "16629050.0",
"total_supply": "16629050.0",
"percent_change_1h": "-0.59",
"percent_change_24h": "-1.12",
"percent_change_7d": "16.59",
"last_updated": "1508253251",
"price_eur": "4803.1770744",
"24h_volume_eur": "1571297824.8",
"market_cap_eur": "79872271729.0"
}
]
GBP:
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "5648.67",
"price_btc": "1.0",
"24h_volume_usd": "1847890000.0",
"market_cap_usd": "93932015864.0",
"available_supply": "16629050.0",
"total_supply": "16629050.0",
"percent_change_1h": "-0.59",
"percent_change_24h": "-1.12",
"percent_change_7d": "16.59",
"last_updated": "1508253251",
"price_gbp": "4276.28608281",
"24h_volume_gbp": "1398932189.27",
"market_cap_gbp": "71110575085.0"
}
]
API in question: https://coinmarketcap.com/api/
Thanks!
>>(json)`
– Alexander Petrov Oct 17 '17 at 15:40