Description

JsonString is an object that refers to a constant string in RAM. You can see it a a supercharged const char* that supports:

  • comparison operations
  • non-zero-terminated strings
  • NUL characters inside the string

It is similar to std::string_view.

Interface

class JsonString {
 public:
  JsonString(const char* p=0, bool isStatic=false);
  JsonString(const char* p, size_t n, bool isStatic=false);
  
  size_t size() const;
  const char* c_str() const;
  bool isStatic() const;
};

ArduinoJson 7.3: the isStatic flag indicates that the string is safe to store by address.

See also

Global warming stripes by Professor Ed Hawkins (University of Reading)