Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Jan 17, 2018
1 parent eb48369 commit bdf7aa7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ HEAD
* Changed the rules of string duplication (issue #658)
* Changed the return type of `strdup()` to `const char*` to prevent double duplication
* Marked `strdup()` as deprecated
* Added support for `String` and Flash string in `RawJson()`
* `RawJson` strings are duplicated according to the same rules

> ### New rules for string duplication
Expand Down
3 changes: 3 additions & 0 deletions examples/ProgmemExample/ProgmemExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ void setup() {
// JsonBuffer.
root["sensor"] = F("gps");

// It works with RawJson too:
root["sensor"] = RawJson(F("\"gps\""));

// You can compare the content of a JsonVariant to a Flash String
if (root["sensor"] == F("gps")) {
// ...
Expand Down
3 changes: 3 additions & 0 deletions examples/StringExample/StringExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void setup() {
// WARNING: the content of the String will be duplicated in the JsonBuffer.
root["sensor"] = sensor;

// It works with RawJson too:
root["sensor"] = RawJson(sensor);

// You can also concatenate strings
// WARNING: the content of the String will be duplicated in the JsonBuffer.
root[String("sen") + "sor"] = String("gp") + "s";
Expand Down

0 comments on commit bdf7aa7

Please sign in to comment.