The best way to parse a JSON in Dart

后端 未结 6 2025
温柔的废话
温柔的废话 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条回答
  •  轮回少年
    2020-12-09 17:09

    Simply use json of the dart:convert package. Here is an example :

    import 'dart:convert';
    
    main() {
      final myJsonAsString = '{"a": 1, "b": "c"}';
      final decoded = json.decode(myJsonAsString);
      ....
    }
    

    See Parsing JSON for more details.

提交回复
热议问题