serialized() allows you to insert preformatted chunks of JSON (or MessagePack) in a JsonObject or a JsonArray.

Unlike with regular string value, ArduinoJson doesn’t escape the special characters when the string is marked as “serialized.”

You can use this function when you have a part of the document that never changes; you can hard-code this part in the source code, to optimize the serialization.

You can also use this function to insert a part that you cannot recreate with the library.


SerializedValue serialized(const char *value);
SerializedValue serialized(const char *value, size_t size);
SerializedValue serialized(char *value); // see Remarks
SerializedValue serialized(char *value, size_t size); // see Remarks
SerializedValue serialized(const String &value); // see Remarks
SerializedValue serialized(const std::string &value); // see Remarks
SerializedValue serialized(const __FlashStringHelper *value); // see Remarks
SerializedValue serialized(const __FlashStringHelper *value, size_t size); // see Remarks

Return value

serialized() returns a type that is recognized by the library as a raw value that should be


As usual, ArduinoJson makes a copy of the string in the JsonDocument, except when it’s a const char*.

For example:

doc["value"] = serialized(String("[1,2,3]")); // makes a copy
// whereas
doc["value"] = serialized("[1,2,3]"); // makes no copy


StaticJsonDocument<256> doc;
doc["hello"] = serialized("[\"wor\",\"ld!\"]");
serializeJson(doc, Serial);

will write the following string to the serial port: