Skip to content

Commit 8c2a1fa

Browse files
committed
Remplaced char* by char[]
1 parent c844db8 commit 8c2a1fa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ArduinoJsonParser change log
44
v1.1 (unreleased)
55
----
66

7-
* Example: changed `char* json` into `char[] json` so that the byes are not write protected
7+
* Example: changed `char* json` into `char json[]` so that the byes are not write protected
88
* Fixed parsing bug when the JSON contains multi-dimensional arrays
99

1010
v1.0

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Features
2121
Example
2222
-------
2323

24-
char* json = "{\"Name\":\"Blanchon\",\"Skills\":[\"C\",\"C++\",\"C#\"],\"Age\":32,\"Online\":true}";
24+
char json[] = "{\"Name\":\"Blanchon\",\"Skills\":[\"C\",\"C++\",\"C#\"],\"Age\":32,\"Online\":true}";
2525

2626
JsonParser<32> parser;
2727

@@ -66,7 +66,7 @@ To extract data from the JSON string, you need to create a `JsonParser`, and spe
6666
> #### How to choose the number of tokens ?
6767
6868
> A token is an element of the JSON object: either a key, a value, an hash-table or an array.
69-
> As an example the `char* json` on the top of this page contains 12 tokens (don't forget to count 1 for the whole object and 1 more for the array itself).
69+
> As an example the `char json[]` on the top of this page contains 12 tokens (don't forget to count 1 for the whole object and 1 more for the array itself).
7070
7171
> The more tokens you allocate, the more complex the JSON can be, but also the more memory is occupied.
7272
> Each token takes 8 bytes, so `sizeof(JsonParser<32>)` is 256 bytes which is quite big in an Arduino with only 2KB of RAM.
@@ -85,7 +85,7 @@ If you need other type, you can get the string value and parse it yourself.
8585

8686
#### Hash-table
8787

88-
Consider we have a `char* json` pointing to the following JSON string:
88+
Consider we have a `char json[]` containing to the following JSON string:
8989

9090
{
9191
"Name":"Blanchon",
@@ -120,7 +120,7 @@ And then extract the member you need:
120120

121121
#### Array
122122

123-
Consider we have a `char* json` pointing to the following JSON string:
123+
Consider we have a `char json[]` containing to the following JSON string:
124124

125125
[
126126
[ 1.2, 3.4 ],
@@ -196,7 +196,7 @@ because the local variable `parser` will be *removed* from memory when the funct
196196

197197
This will probably never be an issue, but you need to be aware of this feature.
198198

199-
When you pass a `char*` to `JsonParser::parseArray()` or `JsonParser::parseHashTable()`, the content of the string will be altered to add `\0` at the end of the tokens.
199+
When you pass a `char[]` to `JsonParser::parseArray()` or `JsonParser::parseHashTable()`, the content of the string will be altered to add `\0` at the end of the tokens.
200200

201201
This is because we want functions like `JsonArray::getString()` to return a null-terminating string without any memory allocation.
202202

0 commit comments

Comments
 (0)