bblanchon / ArduinoJson

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

Error compiling example code SimpleParser on Arduino Web Editor NodeMCU 0.9 #2099

Closed cryptIOT closed 4 months ago

cryptIOT commented 4 months ago

Description Console Output : /usr/local/bin/arduino-cli compile --fqbn esp8266:esp8266:nodemcu:baud=115200,xtal=80,eesz=4M,dbg=Disabled,lvl=None____,ip=lm2f,vt=flash,exception=disabled,wipe=none --build-cache-path /tmp --output-dir /tmp/1555963679/build --build-path /tmp/arduino-build-67B333C02B32F6F77E3AD68F8F18323C /tmp/1555963679/JsonParserExample_copy-1

In file included from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Numbers/FloatTraits.hpp:13:0, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Numbers/convertNumber.hpp:15, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Variant/VariantData.hpp:9, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Variant/VariantAttorney.hpp:9, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Variant/JsonVariantConst.hpp:14, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Variant/VariantRefBase.hpp:9, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Array/ElementProxy.hpp:7, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Array/JsonArray.hpp:7, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson.hpp:29, from /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson.h:9, from /tmp/1555963679/JsonParserExample_copy-1/JsonParserExample_copy-1.ino:9: /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of 'const T ArduinoJson::V704PB2::detail::pgm_read(const T const) [with T = char]': /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Deserialization/DeserializationError.hpp:85:42: required from here /home/builder/Arduino/libraries/arduinojson_7_0_4/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:25:52: error: 'const void' is not a pointer-to-object type return reinterpret_cast<const T*>(pgm_read_ptr(p)); ^ Multiple libraries were found for "ArduinoJson.h" Used: /home/builder/opt/libraries/arduinojson_7_0_4 Not used: /home/builder/opt/libraries/thingesp_1_3_0 Not used: /home/builder/opt/libraries/iotkme_3_0_1 Not used: /home/builder/opt/libraries/coogleiot_1_3_1 Not used: /home/builder/opt/libraries/allthingstalk_lte_m_sdk_2_0_4 Not used: /home/builder/opt/libraries/balemessengerbot_arduino_0_1_0 Not used: /home/builder/opt/libraries/thingsiot_1_2_0 Not used: /home/builder/opt/libraries/antares_esp8266_mqtt_0_9_2 Not used: /home/builder/opt/libraries/cmmc_mqtt_connector_1_3_3 Not used: /home/builder/opt/libraries/antares_esp8266_http_1_3_3 Error during build: exit status 1

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

Reproduction code

// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2024, Benoit BLANCHON
// MIT Licens
//
// This example shows how to deserialize a JSON document with ArduinoJson.
//
// https://arduinojson.org/v7/example/parser/

#include <ArduinoJson.h>

void setup() {
  // Initialize serial port
  Serial.begin(9600);
  while (!Serial)
    continue;

  // Allocate the JSON document
  JsonDocument doc;

  // JSON input string.
  const char* json =
      "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

  // Deserialize the JSON document
  DeserializationError error = deserializeJson(doc, json);

  // Test if parsing succeeds
  if (error) {
    Serial.print(F("deserializeJson() failed: "));
    Serial.println(error.f_str());
    return;
  }

  // Fetch the values
  //
  // Most of the time, you can rely on the implicit casts.
  // In other case, you can do doc["time"].as<long>();
  const char* sensor = doc["sensor"];
  long time = doc["time"];
  double latitude = doc["data"][0];
  double longitude = doc["data"][1];

  // Print the values
  Serial.println(sensor);
  Serial.println(time);
  Serial.println(latitude, 6);
  Serial.println(longitude, 6);
}

void loop() {
  // not used in this example
}

// See also
// --------
//
// https://arduinojson.org/ contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// deserialization problem.
//
// The book "Mastering ArduinoJson" contains a tutorial on deserialization.
// It begins with a simple example, like the one above, and then adds more
// features like deserializing directly from a file or an HTTP request.
// Learn more at https://arduinojson.org/book/
// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤

Remarks Any solution?

bblanchon commented 4 months ago

Hi @cryptIOT,

error: 'const void*' is not a pointer-to-object type

This error is not due to ArduinoJson but to the Core library. See arduino/ArduinoCore-API#118, #1442, #1519, #1536, #1591, #1676, #1790, and #1874.

You can work around this bug by defining ARDUINOJSON_ENABLE_PROGMEM to 0. The ArduinoJson Troubleshooter would have told you that if you had looked a the error list more carefully.

Best regards, Benoit