path_selector

Last updated:

0 purchases

path_selector Image
path_selector Images
Add to Cart

Description:

path selector

Simply extract required values from specific paths in a Map or a List, for now it works for strings keys
Usage #
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": "[email protected]",
"facebook": "https://fb.me/alash3al",
"github": "https://github.com/alash3al"
},
"some.dot-key.included": "Works!",
"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: [email protected]
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"));

// will print: null
print(map.select("skills2.unknown_key.value"));

// will print: Works!
print(map.select("some\\.dot-key\\.included"));
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.