【发布时间】:2014-04-06 01:39:42
【问题描述】:
您好,我正在尝试从我的 arduino 中的网络服务器解析 JSON 响应,以便打开和关闭 LED 灯。我正在使用 wifi 客户端重复示例向我的服务器发出 get 请求:
http://arduino.cc/en/Tutorial/WiFiWebClientRepeating
这是我运行时从串口打印回来的内容
WiFiClient client;
char c = client.read();
Serial.write(c);
串口结果
connecting...
HTTP/1.1 200 OK
Date: Sun, 06 Apr 2014 01:14:37 GMT
Server: Apache
X-Powered-By: PHP/5.5.10
Cache-Control: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: expires=Sun, 06-Apr-2014 03:14:37 GMT; Max-Age=7200; path=/; httponly
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
19
{"lightstatus":"on"}
0
如何仅解析此响应的 JSON 部分,以便可以使用它来控制我的 LED?
谢谢
【问题讨论】:
-
你为什么不直接从json对象开始解析呢?
-
什么意思?有没有从 WiFiClient 对象中只获取 JSON 的函数?
标签: c++ c json arduino arduino-uno