Skip to content

Commit 40f0cb5

Browse files
authored
Initial
1 parent a651659 commit 40f0cb5

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

README.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
11
# jsonlib
2-
Simple JSON parsing library
2+
Simple JSON parsing library for arduino
3+
4+
jsonlib
5+
=======
6+
Simple JSON parsing library for arduino
7+
8+
## Usage example
9+
10+
```c++
11+
String posStr = jsonExtract(json, "coord"); // {"lon":-77.35,"lat":38.93}
12+
float lat = jsonExtract(posStr, "lat").toFloat(); // 38.93
13+
float lon = jsonExtract(posStr, "lon").toFloat(); // -77.35
14+
String weather_list = jsonExtract(json, "weather"); // [{"id":500,"main":"Rain","description":"light rain","icon":"10d"}]
15+
Serial.print("weather_list:");
16+
Serial.println(weather_list);
17+
String weather_0 = jsonIndexList(weather_list, 0); // {"id":500,"main":"Rain","description":"light rain","icon":"10d"}
18+
Serial.print("weather_0:");
19+
Serial.println(weather_0);
20+
String desc = jsonExtract(weather_0, "description"); // light rain
21+
Serial.printf("Location:%f,%f. Current conditions: %s", lat, lon, desc.c_str());
22+
```
23+
24+
## Reference
25+
26+
### jsonExtract
27+
28+
```c++
29+
String jsonIndexList(String json, int idx);
30+
```
31+
32+
Returns a String containing indexed item from provided String containing a json object.
33+
34+
```c++
35+
String jsonExtract(String json, String name);
36+
```
37+
38+
Returns a String containing the named item from provided String containing a json object.
39+
Adds a custom time when the sun reaches the given angle to results returned by `SunCalc.getTimes`.

0 commit comments

Comments
 (0)