ArduinoJson 5.13.0 is out!

The new version of ArduinoJson is out! It brings a few improvements concerning the duplication of strings.

New rules for string duplications

When a program adds a string, ArduinoJson stores it differently depending on the type of the string.

In previous versions, ArduinoJson stored a pointer when the string was a plain old C string (char*, const char*, char[]), but stored a copy when the string had any other type (String, Flash strings…).

ArduinoJson 5.13 changes the rules: now, only const char* are stored with a pointer, all other string types are duplicated, which greatly simplifies our programs.

String

Storage

const char*

pointer

char*

pointer copy

String

copy

const __FlashStringHelper*

copy

Example

Since older versions stored char[] strings with a pointer, we used to see curious behavior when adding strings in a loop. To prevent ArduinoJson for storing the same pointer (an thus the same string) several times, we had to call JsonBuffer::strdup():