Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1311
Closed
Open
Issue created Jul 13, 2020 by Administrator@rootContributor

'getOrAddElement': is not a member of ElementProxy::JsonDocument &>' (reopened issue)

Created by: ewaldc

  • short description of the problem This error is generated when compiling src/extras/tests/ElementProxy/subscript.cpp
  • target platform Windows 10 x64, AJ 6.15.2 (GitHub master)
  • compiler model and version Microsoft Visual Studio Enterprise 2017 Version 15.9.24 +28307.1177 Microsoft Visual C++ 2017
  • MVCE (https://stackoverflow.com/help/mcve)
#include <ArduinoJson.h>
#include <catch.hpp>

using namespace ARDUINOJSON_NAMESPACE;

TEST_CASE("MemberProxy::operator[]") {
  DynamicJsonDocument doc(4096);
  ElementProxy<JsonDocument&> ep = doc[1];

  SECTION("set member") {
    ep["world"] = 42;

    REQUIRE(doc.as<std::string>() == "[null,{\"world\":42}]");
  }

  SECTION("set element") {
    ep[2] = 42;   // ---> **error is here**

    REQUIRE(doc.as<std::string>() == "[null,[null,null,42]]");
  }
}
  • compiler output Error C2039 'getOrAddElement': is not a member of 'ArduinoJson6152_1100000::ElementProxy<ArduinoJson6152_1100000::JsonDocument &>' ElementProxyTest c:\users\ewald\documents\visual studio 2017\projects\openhabesp_test\src\arduinojson\array\elementproxy.hpp 163

As I was validating my 5.x port for relocatable VariantSlot onto v6.x, I stumbled on this test that refused to compile. When substituted for the original AJ 6.15.2/Head, it seems the compiler generates the same error.

The problem is solved by adding the following lines here

  FORCE_INLINE VariantRef getOrAddElement(size_t index) const {
    return getOrAddUpstreamElement().getOrAddElement(index);

Apologies for the extra time taken. I had to redo the port to 6.15.2 as I was unable to keep the 200 test nodes alive on 6.15.1 for a week. Somehow it all works OK in 6.15.2, but that took a bit more time to port (e.g. the new way to implement VariantCompare using the Visitor was a bit of a challenge).

Could you reopen this issue?

Assignee
Assign to
Time tracking