flavio / qjson

QJson is a qt-based library that maps JSON data to QVariant objects.
http://qjson.sourceforge.net
GNU Lesser General Public License v2.1
288 stars 140 forks source link

Fix parsing from QIODevice #98

Closed gooseensky closed 7 years ago

gooseensky commented 7 years ago

[] Move parsing to private class; [] Use same entry point for both parse() API;

gooseensky commented 7 years ago

When reading from QNetworkReply all data will be read at once. It breaks internal logic, please check the following places: https://github.com/flavio/qjson/blob/master/src/json_scanner.cc#L3214, https://github.com/flavio/qjson/blob/master/src/json_scanner.cpp#L74, https://github.com/flavio/qjson/blob/master/src/json_scanner.cc#L3983

Will fix https://github.com/flavio/qjson/issues/52

Some logs for fail case: 23:28:25.686 DEBUG OAuthenticator:113 "code=6336001&client_id=36f9cfadbf8c4f87ae9fbead439a8a6d&client_secret=afb61b309d144fdab1c49fd2014c60b1&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fclementine-data.appspot.com%2Foauth" 23:28:25.808 DEBUG unknown Data available before read: 222
23:28:25.808 DEBUG unknown Bytes read: 222
23:28:25.808 DEBUG unknown Data available after read: 0
23:28:25.808 DEBUG unknown Data available before read: 0
23:28:25.808 ERROR unknown JSonScanner::yylex - error while reading from io device
23:28:25.808 ERROR unknown json_parser - syntax error found, forcing abort, Line 1 Column 1

flavio commented 7 years ago

I just added travis CI support, could you rebase this PR against master to enable travis runs on this PR?

flavio commented 7 years ago

I manually cherry-picked your fixed into master, you did a merge instead of a rebase. That would have polluted the history of the repo ;)

gooseensky commented 7 years ago

Sorry for this. And thanks for help!