-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't parse json from allocine #25
Comments
I found the origin of the problem. |
That's not good, I'm going to fix the issue. |
I have some problems reproducing the issue, could you paste the json file here? I cannot access it anymore. |
Just now i can't. But the probleme is easily reproductible with random json. |
I cannot reproduce the issue. I tried to parse the same json data 3 times in a row using the same parser. I've also tried to parse a json object followed by another one (all repeated 3 times) but nothing happened. Do you know how to reproduce the issue? |
In my test, i was parsing around 10 different json content. i will try to create a testcase tomorrow and send u. |
Hi, Here is a crappy export of the incrimined code that should reproduce the problem. Regards,
QJson::Parser parser;
bool ok;
QVariantMap json = parser.parse( data.toUtf8(), &ok ).toMap(); // data is reply for url 1
const QVariantMap feed = json[ "feed" ].toMap();
const QVariantList movies = feed.value( "movie" ).toList();
if ( !ok || feed.isEmpty() ) {
qWarning() << "JSon error:" << parser.errorString();
return;
}
foreach ( const QVariant& variant, movies ) {
QVariantMap movie = variant.toMap();
const QString id = movie.value( "code" ).toString();
if ( id.isEmpty() ) {
continue;
}
QNetworkReply* reply = createReply( id, driver ); // url for each movie, represented by url 2 to 7, the call is normally sync by using a QEventLoop, but feel free to get all json, and loop over a lsit of QByteArray as alternative to using QNAM.
if ( !reply ) {
continue;
}
const QByteArray releaseData = reply->readAll(); // bytearray of current reply
json = parser.parse( releaseData, &ok ).toMap();
reply->deleteLater();
if ( !ok ) { // normally if u reproduce the bug, u should receive here bad result for good json ( except for url returning ip loggued error from the server )
qWarning() << "JSon error:" << parser.errorString();
continue;
}
movie = json.value( "movie" ).toMap();
qWarning() << movie;
} |
A copy of the json files is available here in case more time is needed: |
Ok, I quickly adapted the code I wrote to use the json data you posted. Unfortunately I cannot reproduce it. Could you take a look at commit 550cada (which is inside of the issue_25 branch) and tell me if something is missing? |
@pasnox could you checkout this branch and run the unit tests? That would be really useful. |
Hi, I recall that for having the bug, at least one of the json content received was an error ip loggued from server. Goog / Bad / Goog / Good / Good / Good / Bad / Bad / Good may be a good test. |
Fixed on master. |
Great! thanks |
The parser ( tested in both branches, master / 1.0.0 ) is not able to parse correctly content from AlloCiné.
You can get a copy of the json here: http://api.allocine.fr/rest/v3/movie?code=53300&format=json&mediafmt=mp4-hip&partner=100043982026&profile=large&sed=20130514&sig=rD6tw9RCQS3dpccdrYMyD3gWhk4%3D
The parser return false, but strangely the returned qvariant seem to have some content inside ?
Thanks,
The text was updated successfully, but these errors were encountered: