deep_pick 0.3.0 copy "deep_pick: ^0.3.0" to clipboard
deep_pick: ^0.3.0 copied to clipboard

outdated

A library to access deep nested values inside of dart data structures, like returned from `dynamic jsonDecode(String source)`.

example/deep_pick_example.dart

// ignore_for_file: avoid_print
import 'dart:convert';

import 'package:deep_pick/deep_pick.dart';

void main() {
  final json = jsonDecode('''
{
  "shoes": [
     { 
       "id": "421",
       "name": "Nike Zoom Fly 3",
       "tags": ["cool", "new"]
     }
  ]
}
''');

  final name = pick(json, 'shoes', 0, 'name').asString();
  print(name); // Nike Zoom Fly 3

  final manufacturer = pick(json, 'shoes', 0, 'manufacturer').asStringOrNull();
  print(manufacturer); // null

  final id = pick(json, 'shoes', 0, 'id').asInt();
  print(id); // 421

  final tags = pick(json, 'shoes', 0, 'tags').asListOrEmpty<String>();
  print(tags); // [cool, new]
}
138
likes
0
pub points
92%
popularity

Publisher

verified publisherpascalwelsch.com

A library to access deep nested values inside of dart data structures, like returned from `dynamic jsonDecode(String source)`.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on deep_pick