How to fix ArduinoJson error: ‘ArduinoJson::JsonObject’ has no member named ‘printTo’


While trying to build your project using ArduinoJson, you see an error message like

src\main.cpp:26:12: error: 'ArduinoJson::JsonObject' has no member named 'printTo'


The code you’re using is for an older version of ArduinoJson: It was written for ArduinoJson version 5.x while you’re using ArduinoJson version 6.x. Use serializeJson() instead of  root.printTo(*response):

serializeJson(root, *response);

See the official ArduinoJson guide for Migrating from version 5 to 6 for further information on which calls you need to replace.