0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Flutterで二次元配列のJSONをDecodeする

Posted at

二次元配列をDecodeしたかっただけやねん(´・ω:;.:...

一旦List<dynamic>にしてからList<List<int>>にすればできました。

List<dynamic>.from(jsonDecode("json文字列"))
    .map((line) => List<int>.from(line))
    .toList();

お試し

    // 二次元配列をJSONに
    var array2d = [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9]
    ];
    var jsonStr = jsonEncode(array2d);

    // 二次元配列に変換
    List<List<int>> decodedArray2d = List<dynamic>.from(jsonDecode(jsonStr))
        .map((line) => List<int>.from(line))
        .toList();

    print(decodedArray2d);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?