path_selector 1.0.1 copy "path_selector: ^1.0.1" to clipboard
path_selector: ^1.0.1 copied to clipboard

outdated

extract values from Map/List using dot-seprated strings you don't have to cast multiple times to fetch a simple values, this is very useful while working with i.e json data

example/path_selector_example.dart

import 'dart:convert';

import 'package:path_selector/path_selector.dart';

void main() {
  final Map<String, dynamic> map = jsonDecode('''
    {
      "name": "Mohamed Al Ashaal",
      "age": 28,
      "contacts": {
        "email": "m7medalash3al@gmail.com",
        "facebook": "https://fb.me/alash3al",
        "github": "https://github.com/alash3al"
      },
      "skills": [
        {
          "name": "PHP",
          "rating": 0.9
        },
        {
          "name": "Golang",
          "rating": 0.9
        },
        {
          "name": "Python",
          "rating": 0.9
        }
      ]
    }
    ''');

  // will print: Mohamed Al Ashaal
  print(map.select("name"));

  // will print: 20
  print(map.select("age"));

  // will print: m7medalash3al@gmail.com
  print(map.select("contacts.email"));

  // will print: [{name: PHP, rating: 0.9}, {name: Golang, rating: 0.9}, {name: Python, rating: 0.9}]
  print(map.select("skills"));

  // will print {name: PHP, rating: 0.9}
  print(map.select("skills.#0"));

  // will print PHP
  print(map.select("skills.#0.name"));
}
6
likes
0
points
48
downloads

Publisher

verified publisheralash3al.com

Weekly Downloads

extract values from Map/List using dot-seprated strings you don't have to cast multiple times to fetch a simple values, this is very useful while working with i.e json data

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on path_selector