Hi,
I’m working on a library to interact with MediaWiki sites. Through the library,
you perform a request to a MediaWiki server, which (usually) answers with JSON
data. But I want to be able to let the library user know when that is not the
case.
So, I’m writing a unit test where the server answers with a non-empty string
that is clearly *not* JSON. I was expecting that the parser would turn the “ok”
variable to “false” in this case, however that is not what happens. Instead,
the parser keeps “ok” to “true”, but a call to qCritical() is made. This is the
code:
bool ok = false;
data = parser.parse(QString("<?xml ?>").toUtf8(), &ok).toMap();
if (!ok)
{
// I was expecting the code to get here.
}
else
{
// Instead, here we are.
}
An the output goes:
QSYSTEM: ReplyTest::incorrectJSON() JSonScanner::yylex - unknown char,
returning -1
So, is there any other way that I can check whether or not the string is valid
JSON? Or do I have to somehow catch that call to qCritical()?
Many thanks,
Adrian
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
QJson-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qjson-devel