bblanchon / ArduinoJson

📟 JSON library for Arduino and embedded C++. Simple and efficient.
https://arduinojson.org
MIT License
6.63k stars 1.1k forks source link

conversion from ‘ArduinoJson::V704HB42::detail::enable_if<true, ArduinoJson::V704HB42::JsonVariantConst>::type’ {aka ‘ArduinoJson::V704HB42::JsonVariantConst’} to ‘ArduinoJson::V704HB42::JsonDocument’ is ambiguous #2091

Closed folkertvanheusden closed 1 month ago

folkertvanheusden commented 1 month ago

Description I've got:

class myobject {
public:
static myobject *deserialize(const JsonDocument j);
};

furthermore:

void wrapper(const JsonDocument j) {
    myobject *m = myobject::deserialize(j["myobject"]);
}

This results in the error shown in the topic:

error: conversion from ‘ArduinoJson::V704HB42::detail::enable_if<true, ArduinoJson::V704HB42::JsonVariantConst>::type’ {aka ‘ArduinoJson::V704HB42::JsonVariantConst’} to ‘ArduinoJson::V704HB42::JsonDocument’ is ambiguous

Troubleshooter's report

  1. The program uses ArduinoJson 7
  2. The issue happens at compile time
  3. The error is not in the list

Environment

folkertvanheusden commented 1 month ago

I learned that when loading, use JsonDocument and from then on use JsonVariant.