如何在curl命令Arduino中转义JSON字符

时间:2019-04-20 11:31:15

标签: curl arduino

我想在Linux arduino YUN中使用curl命令,在curl命令中包含JSON应用程序。我的命令可以在linux终端中运行,但是当在arduino IDE中使用runShellCommandAsynchronously()运行时; curl命令不执行。

process Fav;
Fav.runShellCommandAsynchronously("curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -H 'apiKey:eyJh-CV5GrI0jg_r1nDzg' -d '{\"device_developer_id\" : \"ArduinoYun@haikal\", \"data\":{\"WaterLevel\": "+String(volume)+"} }' -g 'http://api.favoriot.com/v1/streams'");

它应该执行curl命令返回200 OK状态。而且我相信问题是JSON中的转义字符。如何在arduino函数的JSON中转义特殊字符:

runShellCommandAsynchronously()

该函数中的我的JSON数据:

-d '{\"device_developer_id\" : \"ArduinoYun@haikal\", \"data\":{\"WaterLevel\": "+String(volume)+"} }'

0 个答案:

没有答案