stringstream not working on esp32
Created by: LeonB
I'm using ArduinoJson on an esp32.
This works:
DynamicJsonDocument doc(1024);
doc["reading"] = "test";
String s;
serializeJson(doc, s);
Serial.println(s);
This works:
DynamicJsonDocument doc(1024);
doc["reading"] = "test";
std::string s;
serializeJson(doc, s);
Serial.println(s.c_str());
But as soon as I try to use std::stringstream
I get a compile error:
DynamicJsonDocument doc(1024);
doc["reading"] = "test";
std::stringstream ss();
serializeJson(doc, ss);
libraries/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp:129:13: required from 'void ArduinoJson6130_000001::TextFormatter<TWriter>::writeRaw(const char*) [with TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>]'
libraries/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:80:5: required from 'void ArduinoJson6130_000001::JsonSerializer<TWriter>::visitNull() [with TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>]'
libraries/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp:16:5: required from 'void ArduinoJson6130_000001::variantAccept(const ArduinoJson6130_000001::VariantData*, Visitor&) [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp:352:18: required from 'void ArduinoJson6130_000001::VariantConstRef::accept(Visitor&) const [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp:20:39: required from 'void ArduinoJson6130_000001::JsonDocument::accept(Visitor&) const [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:15:3: required from 'size_t ArduinoJson6130_000001::doSerialize(const TSource&, TWriter) [with TSerializer = ArduinoJson6130_000001::JsonSerializer; TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>; size_t = unsigned int]'
libraries/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:23:34: required from 'size_t ArduinoJson6130_000001::serialize(const TSource&, TDestination&) [with TSerializer = ArduinoJson6130_000001::JsonSerializer; TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TDestination = std::__cxx11::basic_stringstream<char>(); size_t = unsigned int]'
libraries/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:102:35: required from 'size_t ArduinoJson6130_000001::serializeJson(const TSource&, TDestination&) [with TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TDestination = std::__cxx11::basic_stringstream<char>(); size_t = unsigned int]'
src/Server.ino:92:26: required from here
libraries/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp:22:29: error: request for member 'write' in '*((ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>*)this)->ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>::_dest', which is of non-class type 'std::__cxx11::basic_stringstream<char>()'
return _dest->write(s, n);
^
libraries/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp: In instantiation of 'size_t ArduinoJson6130_000001::Writer<TDestination, Enable>::write(uint8_t) [with TDestination = std::__cxx11::basic_stringstream<char>(); Enable = void; size_t = unsigned int; uint8_t = unsigned char]':
libraries/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp:146:13: required from 'void ArduinoJson6130_000001::TextFormatter<TWriter>::writeRaw(char) [with TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>]'
libraries/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp:69:15: required from 'void ArduinoJson6130_000001::TextFormatter<TWriter>::writeFloat(T) [with T = float; TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>]'
libraries/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:56:5: required from 'void ArduinoJson6130_000001::JsonSerializer<TWriter>::visitFloat(ArduinoJson6130_000001::Float) [with TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>; ArduinoJson6130_000001::Float = float]'
libraries/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp:30:51: required from 'void ArduinoJson6130_000001::VariantData::accept(Visitor&) const [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp:14:5: required from 'void ArduinoJson6130_000001::variantAccept(const ArduinoJson6130_000001::VariantData*, Visitor&) [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp:352:18: required from 'void ArduinoJson6130_000001::VariantConstRef::accept(Visitor&) const [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp:20:39: required from 'void ArduinoJson6130_000001::JsonDocument::accept(Visitor&) const [with Visitor = ArduinoJson6130_000001::JsonSerializer<ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void> >]'
libraries/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:15:3: required from 'size_t ArduinoJson6130_000001::doSerialize(const TSource&, TWriter) [with TSerializer = ArduinoJson6130_000001::JsonSerializer; TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TWriter = ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>; size_t = unsigned int]'
libraries/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:23:34: required from 'size_t ArduinoJson6130_000001::serialize(const TSource&, TDestination&) [with TSerializer = ArduinoJson6130_000001::JsonSerializer; TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TDestination = std::__cxx11::basic_stringstream<char>(); size_t = unsigned int]'
libraries/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:102:35: required from 'size_t ArduinoJson6130_000001::serializeJson(const TSource&, TDestination&) [with TSource = ArduinoJson6130_000001::BasicJsonDocument<ArduinoJson6130_000001::DefaultAllocator>; TDestination = std::__cxx11::basic_stringstream<char>(); size_t = unsigned int]'
src/Server.ino:92:26: required from here
libraries/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp:18:26: error: request for member 'write' in '*((ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>*)this)->ArduinoJson6130_000001::Writer<std::__cxx11::basic_stringstream<char>(), void>::_dest', which is of non-class type 'std::__cxx11::basic_stringstream<char>()'
return _dest->write(c);
^
I've defined ARDUINOJSON_ENABLE_STD_STREAM
:
#define ARDUINOJSON_ENABLE_STD_STREAM 1
In the tests I see std::stringstream
is used. What is going wrong here? I'm using the makeEspArduino makefile.