-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
109 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:json_path/src/result.dart'; | ||
import 'package:json_path/src/selector/selector.dart'; | ||
|
||
class ListUnion extends Selector { | ||
ListUnion(this.keys); | ||
|
||
final List<int> keys; | ||
|
||
@override | ||
Iterable<Result> call(Iterable<Result> results) => results | ||
.map((r) => (r.value is List) ? mapList(r.value, r.path) : []) | ||
.expand((_) => _); | ||
|
||
Iterable<Result> mapList(List list, String path) => keys | ||
.where((key) => key < list.length) | ||
.map((key) => Result(list[key], path + '[$key]')); | ||
|
||
@override | ||
String get expression => '[${keys.join(',')}]'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:json_path/src/quote.dart'; | ||
import 'package:json_path/src/result.dart'; | ||
import 'package:json_path/src/selector/selector.dart'; | ||
|
||
class ObjectUnion extends Selector { | ||
ObjectUnion(this.keys); | ||
|
||
final List<String> keys; | ||
|
||
@override | ||
Iterable<Result> call(Iterable<Result> results) => results | ||
.map((r) => (r.value is Map) ? map(r.value, r.path) : []) | ||
.expand((_) => _); | ||
|
||
Iterable<Result> map(Map map, String path) => keys | ||
.where(map.containsKey) | ||
.map((key) => Result(map[key], path + '[${Quote(key)}]')); | ||
|
||
@override | ||
String get expression => '[${keys.map((k) => Quote(k)).join(',')}]'; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ const _singles = [ | |
'.', | ||
'*', | ||
':', | ||
',', | ||
]; | ||
|
||
const _doubles = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters