skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. You can easly decode Json String in flutter using:

    jsonDecode("Your Json String");
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search