Json库
json library from github arduino Json
Github arduino json wiki | JSON Library 论坛简介贴地址
download from the address:zip address
Welcome to the user manual for the Arduino JSON library, an elegant and efficient JSON library for embedded systems. It's designed to have the most intuitive API, the smallest footprint and works without any allocation on the heap (no malloc). It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project. Using the library with Arduino
Examples
|
- StaticJsonBuffer<200> jsonBuffer; 为JSON对象树创建内存池(在栈上分配内存) 参数
- DynamicJsonBuffer jsonBuffer; 为JSON对象树创建内存池(在堆上分配内存)- 简单但效率低 - JsonObject& root = jsonBuffer.createObject(); 创建对象树的根 - root["sensor"] = "gps"; 在对象中添加值 参数
- JsonArray& data = root.createNestedArray("data"); 在对象中添加一个嵌套的数组 参数
- data.add(double_with_n_digits(48.756080, 6)); 给data数组添加值 参数
- root.printTo(Serial); 打印输出 参数
例:{"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
打印输出(格式) - JsonObject& root = jsonBuffer.parseObject(json); 解析json数据 - sensor = root["sensor"] 取值 - latitude = root["data"][0]; "data":[48.756080,2.302038] 取值
|
更多建议和问题欢迎反馈至 YFRobot论坛