I’am tring to parse a String camed from dio.post method but json.decode(response.data) failed an gave me this error description [log] FormatException: Unexpected character (at character 1)
{"test":"good"},this is not the real response but I use it tring to detect the failure cause ,and even with this short valid json string it failed ,but in the others requests it work correctly
I expect to get Map<String,dynamic> variable but it failed and I cant use dio response directly without decode it
2
Answers
To add a reviver in the json.decode(decodeSource,reviver)
The optional [reviver] function is called once for each object or list property that has been parsed during decoding. The key argument is either the integer list index for a list property, the string map key for object properties, or null for the final result.
The default [reviver] (when not provided) is the identity function.
You can easly decode Json String in flutter using: