The best way to parse a JSON in Dart

后端 未结 6 2028
温柔的废话
温柔的废话 2020-12-09 16:43

I\'m trying to load a json file from a URL and parse it within Dart. So I had tried the following code as suggested from some links when I google for it:

            


        
6条回答
  •  Happy的楠姐
    2020-12-09 17:10

    here is my solution :) At first you need to import the convert package :

         import 'dart:convert';
    
         var res = json.decode(response.body);
    

    then you can get values by key, like below:

         print(res["message"]);
    

提交回复
热议问题