We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
举个例子,如何在v6代码中如何提取json中的city字符串,然后直接让墨水屏显示呢, 墨水屏显示代码如下 void displaytext(){ display.init(115200); display.setRotation(0); u8g2Fonts.begin(display); display.firstPage(); uint8_t SCREEN_WIDTH=400; do { u8g2Fonts.setBackgroundColor(0xff); u8g2Fonts.setForegroundColor(0x00); u8g2Fonts.setFont(u8g2_mfyuanhei_16_gb2312); u8g2Fonts.drawUTF8(250, 150, “测试”); }
while (display.nextPage()); display.hibernate(); } 以下是我的获取json的代码 HTTPClient http; WiFiClient wifiClient; if (WiFi.status() == WL_CONNECTED){ http.begin(wifiClient,"http://whois.pconline.com.cn/ipJson.jsp?ip=xxx.xxx.xxx.xxx&json=true"); int httpCode = http.GET(); Serial.print(httpCode); http.setUserAgent("Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36"); if (httpCode==HTTP_CODE_OK) { String respone = http.getString(); StaticJsonDocument<384> doc; DeserializationError error = deserializeJson(doc, respone); if (error) { Serial.print(F("deserializeJson() failed: ")); Serial.println(error.f_str()); return ; } const char* ip = doc["ip"]; // "202.101.102.194" const char* pro = doc["pro"]; // "福建省" const char* proCode = doc["proCode"]; // "350000" const char* city = doc["city"]; // "福州市" const char* cityCode = doc["cityCode"]; // "350100" const char* region = doc["region"]; // nullptr const char* regionCode = doc["regionCode"]; // "0" const char* addr = doc["addr"]; // "福建省福州市 电信" const char* regionNames = doc["regionNames"]; // nullptr const char* err = doc["err"]; // nullptr http.end(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
举个例子,如何在v6代码中如何提取json中的city字符串,然后直接让墨水屏显示呢,
墨水屏显示代码如下
void displaytext(){
display.init(115200);
display.setRotation(0);
u8g2Fonts.begin(display);
display.firstPage();
uint8_t SCREEN_WIDTH=400;
do
{
u8g2Fonts.setBackgroundColor(0xff);
u8g2Fonts.setForegroundColor(0x00);
u8g2Fonts.setFont(u8g2_mfyuanhei_16_gb2312);
u8g2Fonts.drawUTF8(250, 150, “测试”);
}
while (display.nextPage());
display.hibernate();
}
以下是我的获取json的代码
HTTPClient http;
WiFiClient wifiClient;
if (WiFi.status() == WL_CONNECTED){
http.begin(wifiClient,"http://whois.pconline.com.cn/ipJson.jsp?ip=xxx.xxx.xxx.xxx&json=true");
int httpCode = http.GET();
Serial.print(httpCode);
http.setUserAgent("Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36");
if (httpCode==HTTP_CODE_OK)
{
String respone = http.getString();
StaticJsonDocument<384> doc;
DeserializationError error = deserializeJson(doc, respone);
if (error)
{
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return ;
}
const char* ip = doc["ip"]; // "202.101.102.194"
const char* pro = doc["pro"]; // "福建省"
const char* proCode = doc["proCode"]; // "350000"
const char* city = doc["city"]; // "福州市"
const char* cityCode = doc["cityCode"]; // "350100"
const char* region = doc["region"]; // nullptr
const char* regionCode = doc["regionCode"]; // "0"
const char* addr = doc["addr"]; // "福建省福州市 电信"
const char* regionNames = doc["regionNames"]; // nullptr
const char* err = doc["err"]; // nullptr
http.end();
}
The text was updated successfully, but these errors were encountered: