Assertion error while opening the same JSON file twice using QFIle
-
I have 3 signals and slots, which works with dynamic combo box by reading data from JSON file. I face the following error while executing the code,
ASSERT: "a && i >= 0 && i < (int)a->length" in file serialization\qjsonarray.cpp, line 613
-
I have 3 signals and slots, which works with dynamic combo box by reading data from JSON file. I face the following error while executing the code,
ASSERT: "a && i >= 0 && i < (int)a->length" in file serialization\qjsonarray.cpp, line 613
@dhanush_11
Hello and welcome.This should not have anything to do with "opening the same JSON file twice using QFIle". For whatever reason, something you have has made an array index go out of bounds. Run your code under the debugger and look at the stack trace when it ASSERTs: follow that back to identify a line in your code whence it emanates.
For all I know: if the JSON you are reading is malformed (e.g. you write to file after reading it once) I suppose it might be possible to get an ASSERT. Or maybe you're just trying to access a
QJsonArray
with a bad index. Whatever, nobody will able to answer without more detail. -
Hi and welcome to devnet,
How are you reading that file ?
-
I don't see any adequate grouping of operations in that assert statement so is OP even sure of the conditions under which it occurs? PARENTHESIZE YOUR EXPRESSIONS and DONT USE C-STYLE CASTS in C++
-
@dhanush_11
Hello and welcome.This should not have anything to do with "opening the same JSON file twice using QFIle". For whatever reason, something you have has made an array index go out of bounds. Run your code under the debugger and look at the stack trace when it ASSERTs: follow that back to identify a line in your code whence it emanates.
For all I know: if the JSON you are reading is malformed (e.g. you write to file after reading it once) I suppose it might be possible to get an ASSERT. Or maybe you're just trying to access a
QJsonArray
with a bad index. Whatever, nobody will able to answer without more detail.@JonB Thanks !! That was the issue. Index of JsonArray was the problem. I solved it earlier.