PlatformIO Community

ESP32: 'class String' has no member named 'write'

Hi,
I am using an ESP32 dev module. I am using the Arduino and espidf framework. I am getting this error when building:

Compiling .pio/build/esp-wrover-kit/esp-idf/driver/periph_ctrl.c.o
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Serialization/Writer.hpp: In instantiation of 'size_t ArduinoJson6152_1100010::Writer<TDestination, Enable>::write(uint8_t) [with TDestination = String; Enable = void; size_t = unsigned int; uint8_t = unsigned char]':
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Json/TextFormatter.hpp:148:13:   required from 'void ArduinoJson6152_1100010::TextFormatter<TWriter>::writeRaw(char) [with TWriter = ArduinoJson6152_1100010::Writer<String, void>]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Json/TextFormatter.hpp:70:7:   required from 'void ArduinoJson6152_1100010::TextFormatter<TWriter>::writeFloat(T) [with T = double; TWriter = ArduinoJson6152_1100010::Writer<String, void>]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Json/JsonSerializer.hpp:58:5:   required from 'void ArduinoJson6152_1100010::JsonSerializer<TWriter>::visitFloat(ArduinoJson6152_1100010::Float) [with TWriter = ArduinoJson6152_1100010::Writer<String, void>; ArduinoJson6152_1100010::Float = double]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Variant/VariantData.hpp:40:51:   required from 'void ArduinoJson6152_1100010::VariantData::accept(Visitor&) const [with Visitor = ArduinoJson6152_1100010::JsonSerializer<ArduinoJson6152_1100010::Writer<String, void> >]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Variant/VariantFunctions.hpp:15:5:   required from 'void ArduinoJson6152_1100010::variantAccept(const ArduinoJson6152_1100010::VariantData*, Visitor&) [with Visitor = ArduinoJson6152_1100010::JsonSerializer<ArduinoJson6152_1100010::Writer<String, void> >]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Variant/VariantRef.hpp:350:18:   required from 'void ArduinoJson6152_1100010::VariantConstRef::accept(Visitor&) const [with Visitor = ArduinoJson6152_1100010::JsonSerializer<ArduinoJson6152_1100010::Writer<String, void> >]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Document/JsonDocument.hpp:20:39:   required from 'void ArduinoJson6152_1100010::JsonDocument::accept(Visitor&) const [with Visitor = ArduinoJson6152_1100010::JsonSerializer<ArduinoJson6152_1100010::Writer<String, void> >]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Serialization/serialize.hpp:15:3:   required from 'size_t ArduinoJson6152_1100010::doSerialize(const TSource&, TWriter) [with TSerializer = ArduinoJson6152_1100010::JsonSerializer; TSource = ArduinoJson6152_1100010::BasicJsonDocument<ArduinoJson6152_1100010::DefaultAllocator>; TWriter = ArduinoJson6152_1100010::Writer<String, void>; size_t = unsigned int]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Serialization/serialize.hpp:23:34:   required from 'size_t ArduinoJson6152_1100010::serialize(const TSource&, TDestination&) [with TSerializer = ArduinoJson6152_1100010::JsonSerializer; TSource = ArduinoJson6152_1100010::BasicJsonDocument<ArduinoJson6152_1100010::DefaultAllocator>; TDestination = String; size_t = unsigned int]'
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Json/JsonSerializer.hpp:104:35:   required from 'size_t ArduinoJson6152_1100010::serializeJson(const TSource&, TDestination&) [with TSource = ArduinoJson6152_1100010::BasicJsonDocument<ArduinoJson6152_1100010::DefaultAllocator>; TDestination = String; size_t = unsigned int]'
src/webserver.cpp:254:43:   required from here
/home/maxwell/.platformio/lib/ArduinoJson_ID64/src/ArduinoJson/Serialization/Writer.hpp:18:19: error: 'class String' has no member named 'write'
     return _dest->write(c);

This is my platform.ini file:

[env:esp32dev]

platform = espressif32

board = esp32dev

framework =

arduino

espidf

build_flags = -D ESP32

build_unflags = -Werror=all

monitor_speed = 115200

platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.0

lib_deps =

ESP Async WebServer

AsyncTCP

SHA-1 Hash

ArduinoJson

Could it be because I am using an older version of Arduino-esp32?

I am using the latest version of ArduinoJson

I could only find issue https://github.com/bblanchon/ArduinoJson/issues/1156#issuecomment-569700345 in relation to that, maybe that helps?

Globally installed libraries are bad, per-project managmenet is better. Are you sure the ArduinoJson library is up to date?

Also, what’s the minimal cpp code to reproduce the problem?

1 Like

Thanks for the response. I managed to resolve it.
The code was ported from arduino so it took a while to debug.

  1. The String class in WString.h could not be used. I used std::string instead.
  2. I was using ArduinoJson v6.14 in arduino. v6.15 was causing errors. So I took your advice and removed global libraries and made it per project.