squix78 / json-streaming-parser

Arduino library for parsing potentially huge json streams on devices with scarce memory
MIT License
205 stars 88 forks source link

json-streaming-parser ans ESP8266 error #29

Open nicephore opened 4 years ago

nicephore commented 4 years ago

Hi,

1th sorry for mi bad english write. Hope somebody can help me. I'm try with the demo programm JsonStreamingParser.ino. my Json is like:

char json[] = "{\"observations\":[{\"stationID\":\"IVENES1\",\"obsTimeUtc\":\"2020-01-01T09:44:08Z\",\"obsTimeLocal\":\"2020-01-01 10:44:08\",\"neighborhood\":\"Venesmes\",\"softwareType\":\"EasyWeatherV1.4.4\",\"country\":\"FR\",\"solarRadiation\":34.6,\"lon\":2.30547237,\"realtimeFrequency\":null,\"epoch\":1577871848,\"lat\":46.8543663,\"uv\":0.0,\"winddir\":111,\"humidity\":97,\"qcStatus\":-1,\"metric\":{\"temp\":4,\"heatIndex\":4,\"dewpt\":3,\"windChill\":4,\"windSpeed\":5,\"windGust\":5,\"pressure\":1031.93,\"precipRate\":0.00,\"precipTotal\":0.00,\"elev\":169}}]}";

All i right.

I modified then file ExampleParser.cpp like this:

String currentKey;
char* myArray[] = {"stationID", "neighborhood"};

int getIndexByKey( const char * key ){
  for ( uint8_t i = 0; i < sizeof( myArray ) / sizeof( char * ); i++ )
    if ( !strcmp( key, myArray[i] ) )
      return i;
  return -1;
}

void ExampleListener::key(String key) {
  currentKey = key;
}

void ExampleListener::value(String value) {
  int index = getIndexByKey(currentKey.c_str());
  switch(index){
    case 0:
      Serial.print(" ----------> stationID : ");
      Serial.println(value);
    break;
    case 1:
      Serial.print(" ----------> neighborhood : ");
      Serial.println(value);
    break;
  }
  currentKey = key;
}

This code return then error:

c:/users/f1trn/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\F1TRN\AppData\Local\Temp\arduino_build_556259\sketch\JsonStreamingParser.ino.cpp.o:C:\Users\F1TRN\Desktop\arduino_projet\JSON\test_arduino_JSON\JsonStreamingParser/JsonStreamingParser.ino:6: undefined reference to `vtable for ExampleListener'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "JsonStreamingParser.h" Used: C:\Users\F1TRN\Documents\Arduino\libraries\json-streaming-parser Using library json-streaming-parser at version 1.0.5 in folder: C:\Users\F1TRN\Documents\Arduino\libraries\json-streaming-parser exit status 1 Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Thanks for help

mrcodetastic commented 1 year ago

Try with:

https://github.com/mrfaptastic/json-streaming-parser2

Because this library isn't maintained anymore it seems .