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
  • #441
Closed
Open
Issue created Feb 07, 2017 by Administrator@rootContributor

Compile Error using JsonVariant

Created by: tbnobody

I had the following code running on a ESP8266 using the Arduino Framework:

	StaticJsonBuffer<1024> jsonBuffer;
	JsonObject& root = jsonBuffer.parseObject(json);
	JsonArray& data = root[F("button")];

	uint8_t cnt = 0;

	for (auto dataobj : data) {
		config.Button_Config[cnt].animation = dataobj[F("animation")].as<uint>();
		config.Button_Config[cnt].color = StripeAnimation.ConvertStringToColor(dataobj[F("color")].as<String>());

		cnt++;

		if (cnt > MAX_BUTTON_CONFIG) {
			break;
		}
	}

This code worked perfectly including commit 11432253 and does not work with commit 8499f0b9

I get the following error message:

ArduinoJson.hpp:12: In file included from
ArduinoJson.h:8: from
ArduinoJson.h:8: from
AsyncJson.h:23: from
WebAPI.h:17: from
WebAPI.cpp:8: from
JsonObject.hpp: In instantiation of typename ArduinoJson::Internals::JsonVariantAs<TValue>::type ArduinoJson::JsonObject::get_impl(TStringRef) const [with TStringRef = const __FlashStringHelper*; TValue = ArduinoJson::JsonObjectSubscript<const __FlashStringHelper* const&>; typename ArduinoJson::Internals::JsonVariantAs<TValue>::type = ArduinoJson::JsonObjectSubscript<const __FlashStringHelper* const&>]
JsonObject.hpp:179: required from typename ArduinoJson  Internals  JsonVariantAs<T>  type ArduinoJson  JsonObject  get(const TString*) const [with TValue = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>; TString = __FlashStringHelper; typename ArduinoJson  Internals  JsonVariantAs<T>  type = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>]
JsonObjectSubscript.hpp:64: required from typename ArduinoJson  Internals  JsonVariantAs<T>  type ArduinoJson  JsonObjectSubscript<TKey>  as() const [with TValue = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>; TStringRef = const __FlashStringHelper*; typename ArduinoJson  Internals  JsonVariantAs<T>  type = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>]
JsonVariantBase.hpp:63: required from const typename ArduinoJson  Internals  JsonVariantAs<T>  type ArduinoJson  JsonVariantBase<TImpl>  as() const [with T = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>; TImpl = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper*>; typename ArduinoJson  Internals  JsonVariantAs<T>  type = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>]
JsonVariantBase.hpp:58: required from ArduinoJson  JsonVariantBase<TImpl>  operator T() const [with T = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>; TImpl = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper*>]
JsonVariantBase.hpp:101: required from typename ArduinoJson  TypeTraits  EnableIf<ArduinoJson  Internals  StringTraits<TString>  has_equals, ArduinoJson  JsonObjectSubscript<const TString&> >  type ArduinoJson  JsonVariantBase<TImpl>  operator[](const TString&) [with TString = const __FlashStringHelper*; TImpl = ArduinoJson  JsonVariant; typename ArduinoJson  TypeTraits  EnableIf<ArduinoJson  Internals  StringTraits<TString>  has_equals, ArduinoJson  JsonObjectSubscript<const TString&> >  type = ArduinoJson  JsonObjectSubscript<const __FlashStringHelper* const&>]
WebAPI.cpp:942: required from here
 
JsonObject.hpp: 301:17: error: no matching function for call to 'ArduinoJson::JsonVariant::as()
   return node ? node->content.value.as<TValue>()
JsonObject.hpp:301: note  candidates are

The line 942 in WebAPI.cpp is the following line (as in the above code snippet): config.Button_Config[cnt].animation = dataobj[F("animation")].as<uint>();

I am not very familiar with templates, but due to the fact it worked in the previous versions it's maybe not wanted to throw an error here?

Assignee
Assign to
Time tracking