dart JSON String convert to List String

后端 未结 3 461
南旧
南旧 2021-01-04 10:08

I have an API that calls the json String array as follows:

[
  \"006.01.01\",
  \"006.01.01 1090\",
  \"006.01.01 1090 1090.950\",
  \"006.01.01 1090 1090.95         


        
3条回答
  •  余生分开走
    2021-01-04 10:18

    We can easily parse the JSON into a Dart array without the need of creating any class.

    main() {
      String arrayText = '{"tags": ["dart", "flutter", "json"]}';
    
      var tagsJson = jsonDecode(arrayText)['tags'];
      List tags = tagsJson != null ? List.from(tagsJson) : null;
    
      print(tags);
    }
    

    Now you can see the result of printing the Dart Array.

    [dart, flutter, json]
    

提交回复
热议问题