Comments (1)
Here is the snippet I'm using to test it:
char c[] = "{\"object\":{\"scalar\":123}}";
char d[100];
struct jsonparse_state parser;
int json_type;
// CASE 1
jsonparse_setup(&parser, c, os_strlen(c));
jsonparse_next(&parser);
jsonparse_object_str(&parser, d, 100);
debug("\n\nENTIRE OBJECT: [%s]\n", d);
// CASE 2
jsonparse_setup(&parser, c, os_strlen(c));
while ((json_type = jsonparse_next(&parser)) != 0) {
if (json_type == JSON_TYPE_PAIR_NAME) {
if (jsonparse_strcmp_value(&parser, "object") == 0) {
jsonparse_next(&parser); // JSON_TYPE_PAIR
jsonparse_next(&parser); // JSON_TYPE_OBJECT
jsonparse_object_str(&parser, d, 100);
debug("NESTED OBJECT: [%s]\n", d);
}
}
}
// CASE 3
jsonparse_setup(&parser, c, os_strlen(c));
while ((json_type = jsonparse_next(&parser)) != 0) {
if (json_type == JSON_TYPE_PAIR_NAME) {
if (jsonparse_strcmp_value(&parser, "scalar") == 0) {
jsonparse_next(&parser); // JSON_TYPE_PAIR
jsonparse_next(&parser); // JSON_TYPE_NUMBER
int s = jsonparse_get_value_as_int(&parser);
debug("SCALAR: [%d]\n\n", s);
}
}
}
The output is:
ENTIRE OBJECT: [{"object":{"scalar":123}]
NESTED OBJECT: [{"scalar":123}]
SCALAR: [123]
It is exactly what I'm expecting.
from esp8266.
Related Issues (20)
- WEBCLIENT - no request freeing from list HOT 1
- IoT Firmware Websocket "freezes" on frame segmentation at TCP level HOT 7
- Enhancement: Upgrade SDK to 1.5.1 (16.1.2016) (IoT Firmware) HOT 2
- IoT Firmware: Default config settings after complete flashing HOT 6
- How to adapte 8Mbit flash with iot_firmware project? HOT 1
- What's the purpose of bringing out SD_CLK to SD_CMD? (EVB board) HOT 1
- MQTT example must be updated with changes to PubSubClient HOT 1
- WebClient.webclient_recv - Finishing chunked message hotfix
- Webserver does not respond after reconnect
- Tho functions move into flash instead of RAM HOT 4
- after commit SDK 2.0.0 IoT Firmware won't to compile HOT 8
- RX and TX pin are messed up HOT 1
- it is possible to add webserver/websocket port config in web app HOT 5
- WPA2-PEAP Support HOT 1
- Status/event Messages: field "device" to fill with host name HOT 1
- Compiling Issue HOT 1
- Conection betwen ESPs
- Compile with SDK 2.1.0
- HTML page it's not show in web Server
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 esp8266.