It heavily depends on the content of the file.
My bet is that the string json is pretty big and that it doesn't fit in the StaticJsonBuffer.
The solution, if any, is to use readBytes() instead of readString().
See:
I'd be glad to help you :bowtie:, but I need further information.
Please provide a detailed description of the problem.
:open_mouth:
http://www.nerc.com.pk/Categories/Indigenous
LOL :smile:
My answer was
I'd be glad to help you :bowtie:, but I need further information.
- What did you try?
- What result did you expect?
- What happened instead?
Please provide a detailed description of the problem.
See above.
BTW, please realize that, like most open-source contributors, I do this on my own time, and I do this for free. Time I spend solving your problem is time I don't spend with my kids.
Sentences like "No response?" are totally inappropriate :angry:. I could give you no answer at all, and that would be 100% cool. In fact, that what's happens on many projects, and that's OK because people are busy with other things and we are thankful for what they already gave.
Hi @umer427 , I think your answer to question https://github.com/bblanchon/ArduinoJson/issues/297#issuecomment-223021143 is still incomplete.
OMFG, I think I found the problem!!!!!!!!

Unbelievable!
I guess that's what happens when you write JSON files in Word :smile:
I'm sorry @umer427, ArduinoJson cannot work if the input is not proper JSON.
For the record, you could have spotted the issue using any kind of editor with syntax highlighting.
For example, if I copy/paste the text in GitHub, we can clearly see the quotation marks in red.
{
"scientists":[
{
"name":"Euler",
"x":1,
"y":2,
"orientation":āEā
},
{
"name":"Omar Khayyam",
"x":4,
"y":5,
"orientation":āSā
}
],
"safezones":[
{
"scientist":"Euler",
"x":3,
"y":5,
"orientation":āWā
},
{
"scientist":"Omar Khayyam",
"x":4.5,
"y":5,
"orientation":āā
}
]
}
Did you try to replace readString() by readBytes() as I suggested in my first message?
Did you check each recommendation of FAQ: Why parsing fails?, as I suggested in my first message?
Also, it could help if you tell us what is the actual content of the file... and of course what hardware you're using...
The JsonHttpClient example shows how to use readBytes().
Please try:
// ...unchanged...
#define MAX_FILE_SIZE 1024
#define JSON_BUFFER_SIZE 200
void readFile(const char *fileName, char *buffer, size_t maxSize) {
File file = SD.open(fileName, FILE_READ);
file.readBytes(buffer, maxSize);
file.close();
}
void setup() {
// ...unchanged...
char json[MAX_FILE_SIZE];
readFile("gg.json", json, MAX_FILE_SIZE);
Serial.println(json); // <- SHOW ME THE OUTPUT OF THIS!!!!!
StaticJsonBuffer<JSON_BUFFER_SIZE> jsonBuffer;
// ...unchanged...
}
@umer427 In context of https://github.com/bblanchon/ArduinoJson/issues/297#issuecomment-223525246 refer to main page or directly click here. :wink:
I may sound silly but sometimes I forget to match baud rate, parity etc... I hope that's not the reason :laughing:
@umer427 Your issue is not related to ArduinoJson; here is not the right place to ask for help.
The only advice I can give you is to start with the examples provided with the SD library.
Also, have a look at the documentation for SD library.
Most helpful comment
My answer was
See above.
BTW, please realize that, like most open-source contributors, I do this on my own time, and I do this for free. Time I spend solving your problem is time I don't spend with my kids.
Sentences like "No response?" are totally inappropriate :angry:. I could give you no answer at all, and that would be 100% cool. In fact, that what's happens on many projects, and that's OK because people are busy with other things and we are thankful for what they already gave.