This returns the Object in the debug logs: 'USER_DEBUG [21]|DEBUG|{amount=1825.73, currency=USD}'
I really just want the price and could care less about the currency. How do I strip out just the price?
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.coinbase.com/v2/prices/spot?currency=USD');
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> prices = new List<Object>();
for(Object prc : results.values()) {
prices.add(prc);
}
System.debug('Bitcoin Price:');
for (Object prc : prices) {
// This totally does not work, I want to strip the price value out
Decimal price = prc.amount;
// Above line is the question!
System.debug(prc);
}
}