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

Unexplainable Parsing Issue #33

Closed craiglindley closed 9 months ago

craiglindley commented 9 months ago

StreamJson_Test.zip

I am writing an Internet radio program for the ESP32 and I ran into an interesting issue. My code (contained in the attached zip file) goes out to nl1.api.radio-browser.info to get a list of Internet radio stations of a specified genre and gets back a Json doc which I am trying to parse. I am trying to use this streaming parser because the data returned is to big for ArduinoJson to handle.

The problem I am seeing is related somehow to Cyrillic characters that are returned in the data stream but I cannot say how. If you examine my code in the zip file, which is a complete Arduino program which can be run by a ESP32, you will see a file called AJsonListener.h. Check out line 44 which is shown below:

Serial.printf("\nCurrent Key: %s\n", currentKey);

With this line in place, my code successfully parses all 30 records (as shown in the Serial Monitor) in the returned Json doc. Comment this line out and the code stops after 5 entries are processed. So the absences or presences of this print statement determines if the program runs successfully or not. Very strange.

If anyone can find the cause of this I would appreciate. Also, if I am doing something stupid in this code, let me know.

craiglindley commented 9 months ago

I found out by adding a delay(1) in place of the printf statement my problem goes away