Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
f3ath committed Sep 2, 2020
1 parent 14524b3 commit 734f76d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## [Unreleased]
## [0.0.2] - 2020-09-01
### Fixed
- Last element of array was not selected (regression #1)

## [0.0.1] - 2020-08-03
### Added
- Filters
Expand Down Expand Up @@ -37,7 +41,8 @@
### Added
- Basic design draft

[Unreleased]: https://github.com/f3ath/jessie/compare/0.0.1...HEAD
[Unreleased]: https://github.com/f3ath/jessie/compare/0.0.2...HEAD
[0.0.2]: https://github.com/f3ath/jessie/compare/0.0.1...0.0.2
[0.0.1]: https://github.com/f3ath/jessie/compare/0.0.0+dev.7...0.0.1
[0.0.0+dev.7]: https://github.com/f3ath/jessie/compare/0.0.0+dev.6...0.0.0+dev.7
[0.0.0+dev.6]: https://github.com/f3ath/jessie/compare/0.0.0+dev.5...0.0.0+dev.6
Expand Down
2 changes: 1 addition & 1 deletion lib/src/selector/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Index with SelectorMixin {

@override
Iterable<Result> filter(Iterable<Result> results) => results
.where((r) => r.value is List && r.value.length > index + 1)
.where((r) => r.value is List && r.value.length > index)
.map((r) => Result(r.value[index], r.path + expression()));

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: json_path
version: 0.0.1
version: 0.0.2
description: JSONPath for Dart. JSONPath is XPath for JSON. It is a path in a JSON document.
homepage: "https://github.com/f3ath/jessie"

Expand Down
7 changes: 7 additions & 0 deletions test/json_path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ void main() {
expect(path.filter(json).single.path, r"$['store']['book'][0]['title']");
});

test('Last element of array (regression #1)', () {
final path = JsonPath(r"$['store']['book'][3]['price']");
expect(path.toString(), r"$['store']['book'][3]['price']");
expect(path.filter(json).single.value, 22.99);
expect(path.filter(json).single.path, r"$['store']['book'][3]['price']");
});

test('All in list', () {
final path = JsonPath(r'$.store.book[*]');
expect(path.toString(), r"$['store']['book'][*]");
Expand Down

0 comments on commit 734f76d

Please sign in to comment.