Comments (3)
The original design of the parser API doesn't allow such feature.
So I implemented this feature as a part of a new API for the parser.
Old parser API:
JsonHashTable root = parser.parseHashTable(json);
char* sensor = root.getString("sensor");
long time = root.getLong("time");
double latitude = root.getArray("data").getDouble(0);
double longitude = root.getArray("data").getDouble(1);
New parser API:
JsonObject root = parser.parse(json);
char* sensor = root["sensor"];
long time = root["time"];
double latitude = root["data"][0];
double longitude = root["data"][1];
Iterators, with C++11 syntax:
for (auto i : jsonHashTable) {
cout << "Key " << i.key();
cout << "Value" << (const char*)i->value();
}
for (const char* i : jsonArray) {
cout << "Value" << i;
}
The code is available in the new-parser-api branch
Please give me your feedback.
from arduinojson.
I merged the branch into master
, it's now part of version 3.0
from arduinojson.
Thank you, we will upgrade to the new version soon!
from arduinojson.
Related Issues (20)
- Return JsonDocument from class methods HOT 2
- Question - Access JSON data variables in nested arrays HOT 5
- Problem whith a JSON from Firefox to my ESP8266 HOT 3
- Capped Allocator HOT 4
- fatal error: ArduinoJson/Variant/VariantRefBase.hpp: No such file or directory HOT 1
- Example on ArduinoJson website crashes at runtime HOT 1
- ArduinoJson 7.1.0 Compile error [ invalid use of array with unspecified bounds ] HOT 2
- Missing links to specific types in the API reference HOT 1
- Queuing ArduinoJson objects HOT 3
- Deallocator problem (probably) on ESP32-WROVER-E HOT 3
- Compile errors with new IDE?
- Custom reader: readBytes method is not required? HOT 1
- 'struct SpiRamAllocatorST' has no member named 'reallocate'; did you mean 'deallocate'? HOT 5
- Some trouble using variables as element names in JsonDocument HOT 4
- cppcheck: failed to expand 'ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE' HOT 3
- containsValue() method HOT 2
- Keep a JsonDocument in PSRAM - Container HOT 3
- File deserialization crash HOT 1
- Library fails to parse escaped single quote HOT 6
- Value is always zero HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinojson.