Hi there,
I'm trying to display a specific value from a http get-request. The request is from a value scraped from the website cnbc.com (http://quote.cnbc.com/quote-html-webservice/restQuote/symbolType/symbol?symbols=US10Y&requestMethod=itv&noform=1&partnerId=2&fund=1&exthrs=1&output=json&events=1)
- which gives me this information:
{
"FormattedQuoteResult" : {
"FormattedQuote" : [ {
"symbol" : "US10Y",
"symbolType" : "symbol",
"code" : 0,
"name" : "U.S. 10 Year Treasury",
"shortName" : "US 10-YR",
"onAirName" : "10-Yr T-Note",
"altName" : "US TREASURY-CURRENT 10 YEAR",
"last" : "1.596%",
"last_timedate" : "8:15 AM EDT",
"last_time" : "2021-04-20T08:15:04.000-0400",
"changetype" : "DOWN",
"type" : "BOND",
"subType" : "Government Bond",
"exchange" : "U.S.",
"source" : "Exchange",
"open" : "1.598%",
"high" : "1.633%",
"low" : "1.587%",
"change" : "-0.003",
"change_pct" : "0.00%",
"provider" : "CNBC Quote Cache",
"previous_day_closing" : "1.599%",
"altSymbol" : "US10YT=XX",
"realTime" : "true",
"curmktstatus" : "REG_MKT",
"yrhiprice" : "1.63",
"yrhidate" : "04/20/21",
"yrloprice" : "0.00",
"streamable" : "1",
"bond_last_price" : "95.7344",
"bond_change_price" : "+0.0312",
"bond_change_pct_price" : "+0.0352%",
"bond_open_price" : "95.7188",
"bond_high_price" : "95.8125",
"bond_low_price" : "95.4062",
"bond_prev_day_closing_price" : "95.7031",
"bond_changetype" : "UP",
"maturity_date" : "2031-02-15",
"coupon" : "1.12%",
"issue_id" : "5093160",
"countryCode" : "US",
"timeZone" : "EDT",
"EventData" : {
"is_halted" : "N"
}
} ]
}
}
I would like to dissect only the "last"-value from the above information to be shown on my IDE serial monitor output, for later displayed on an small o-led screen.
My IDE code is currently this:
int httpCode = http.GET(); if (httpCode > 0) // check the returning code { String payload = http.getString(); //Get the request response payload DynamicJsonBuffer jsonBuffer(512); // Parse JSON object JsonObject& root = jsonBuffer.parseObject(payload); if (!root.success()) { Serial.println(F("Parsing failed!")); return; } float USlast = (float)root["FormattedQuoteResult"]["FormattedQuote"]["last"]; Serial.print(USlast);
This gives me the value "0.00".
Please help, how can I get the "last"-value to be shown on the serial output monitor alone?
Thanks in advance.