-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
DIo Causes Random FormatExceptions When Parsing JSON Response. JSON Response is 100% correct Format. #1930
Comments
It is very likely that your JSON content is broken. Without the actual content that breaks, we can not do any thing here. |
here is the JSON response format. {
"success": true,
"responseMessage": "SILVER NOT ENOUGH ",
"responseCode": 1117,
"data": [
{
"item_id": 194,
"silver": 2479.95,
"name": "PUBG Mobile 60 UC",
"description": "PUBG",
"photo": "",
"disable": true
},
{
"item_id": 195,
"silver": 24930,
"name": "PUBG Mobile 600 + 60 UC",
"description": "PUBG",
"photo": "",
"disable": true
},
{
"item_id": 192,
"silver": 12480,
"name": "PUBG Mobile 300 + 25 UC",
"description": "PUBG",
"photo": "",
"disable": true
},
{
"item_id": 102,
"silver": 2850,
"name": "FreeFire USD 1 (100 + 10 Diamonds)",
"description": "FreeFire",
"photo": "",
"disable": true
},
{
"item_id": 104,
"silver": 5700,
"name": "FreeFire USD 2 (210 + 21 Diamonds)",
"description": "FreeFire",
"photo": "",
"disable": true
},
{
"item_id": 103,
"silver": 28500,
"name": "FreeFire USD 10 (1080 + 108 Diamonds)",
"description": "FreeFire",
"photo": "",
"disable": true
},
{
"item_id": 46,
"silver": 29400.000000000004,
"name": "Amazon US USD 10 (US)",
"description": "Amazon US",
"photo": "",
"disable": true
},
{
"item_id": 61,
"silver": 11460,
"name": "Apple & iTunes Card US USD 4 (US)",
"description": "Apple Card US",
"photo": "",
"disable": true
},
{
"item_id": 63,
"silver": 14325.000000000002,
"name": "Apple & iTunes Card US USD 5 (US)",
"description": "Apple Card US",
"photo": "",
"disable": true
},
{
"item_id": 54,
"silver": 5730,
"name": "Apple & iTunes Card US USD 2 (US)",
"description": "Apple Card US",
"photo": "",
"disable": true
},
{
"item_id": 155,
"silver": 27300,
"name": "Nintendo eShop US USD 10 (US)",
"description": "Nintendo eShop US",
"photo": "",
"disable": true
},
{
"item_id": 201,
"silver": 14100,
"name": "Razer Gold 5$ Global",
"description": "Razer Gold Pins",
"photo": "",
"disable": true
},
{
"item_id": 307,
"silver": 2700,
"name": "Jawaker 4250 Token",
"description": "Jawaker 4250 Token",
"photo": "",
"disable": true
},
{
"item_id": 308,
"silver": 13500,
"name": "Jawaker 32500 Token",
"description": "Jawaker 32500 Token",
"photo": "",
"disable": true
},
{
"item_id": 309,
"silver": 27000,
"name": "Jawaker 70000 Token",
"description": "Jawaker 70000 Token",
"photo": "",
"disable": true
},
{
"item_id": 1129,
"silver": 2820,
"name": "Razer Gold - $1 (Global)",
"description": "Razer Gold - USD 1 (Global)",
"photo": "",
"disable": true
},
{
"item_id": 1130,
"silver": 5640,
"name": "Razer Gold - $2 (Global)",
"description": "Razer Gold - USD 2 (Global)",
"photo": "",
"disable": true
},
{
"item_id": 133,
"silver": 57000,
"name": "Mobile Legends 1167 Diamonds",
"description": "Mobile Legends",
"photo": "",
"disable": true
}
]
} I should stress that all other APIs work correctly (until they don't.), and that the JSON format is correct. |
We don't know what happened because you seem to have mounted multiple interceptors. It would be helpful if you could get rid of the project setup and make a minimal reproducible example. |
But from your log, the ending |
The only Interceptor I have setup is the onError. To catch what causes the exception. Without the interceptor it would return a null response with a DioError:[unknown] null. |
I did. And same behavior. Seems like every now and then it throws a JsonFormarException at the same place (always at the very last Json Object in the response array). If the JSON was faulty, wouldn't it not work at all? it's the behavior of sometimes it causes an exception that's puzzling me. |
As far as I can tell this should not be a Dio's problem, but if you can manage to export the raw bytes of the "Malformed" JSON or your API can be shared secretly, send it to cfug-team@googlegroups.com and we'll take a look. |
Sure! I'll be sending the API itself over to you shortly. |
ISSUE HAS BEEN IDENTIFIED It appears that the local testing environment of the company was intercepting the responses and messing with the response (though it looks perfectly fine). Server testing environment was not causing the exception to happen. It's notable that both Dio and http packages caused the same exception at the same place. (http caused it way less times) |
Sounds like |
Package
dio
Version
5.1.1
Output of
flutter doctor -v
Dart Version
3.0.0 stable
Steps to Reproduce
Expected Result
Normal Response from Dio function.
Actual Result
I/flutter ( 8544): onChange -- RewardsCubit, Change { currentState: Instance of 'RewardsLoadingState', nextState: Instance of 'RewardsErrorState' }
[log] FormatException: Unexpected end of input (at character 4344)
...b_category/xhyXu50db7CYmPeZIoo6snFVvjedlVrdhhYAk0ZW.webp","disable":true}]
The text was updated successfully, but these errors were encountered: