flutter json解析

2018-11-20  本文已影响0人  王保全_1098
Map data= json.decode(response);
data[1]['bar'];
Map data= json.decode(response);
var url1= data['current_user_url'];

*实例:

getToken() async {
    Dio dio = new Dio();
    dio.options.baseUrl = ServerUrl.base;
    FormData formData = new FormData.from({
      "mobile": "13981981111",
      "pwd": "983532",
    });
    Response response = await dio.post(ServerUrl.token, data: formData);
    String result = "{\"status\": 0, \"description\": \"success\", \"data\": {\"token\": \"eyJhbGciOiJIUzI1NiJ9.eyJtZW1pZCI6IjEzOTgxOTgzNTMyIiwiY29tcGFueV9pZCI6MjAxNzExMjQzLCJleHAiOjE1NDUyODA5MjB9.3RnJR1i70jD1TUpDn52UTgOrqhhXRZpvS9yMMTD4G74\"}, \"extra\": {\"ssize\": 1, \"snow\": 1542688920, \"other\": null}}";//response.data.toString();
    print(result);
    Map resultMap = json.decode(result);
    String token = resultMap["data"]["token"];
    print(token);
  }
上一篇 下一篇

猜你喜欢

热点阅读