-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for using an ordered dictionary
This isn't part of the JMESPath spec (we use the JSON types and a JSON object has no key order). In order to still accomodate this use case, I've added an Options class that can alter how an expression is interpreted. You can provide a specific dict cls that should be used whenever the interpreter creates a dict as the result of evaluating an expression. This gives people that want this option a way to do it without having to comply with the JMESPath spec. Fixes #89
- Loading branch information
Showing
7 changed files
with
74 additions
and
10 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
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
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,12 @@ | ||
from tests import unittest, OrderedDict | ||
|
||
import jmespath | ||
|
||
|
||
class TestSearchOptions(unittest.TestCase): | ||
def test_can_provide_dict_cls(self): | ||
result = jmespath.search( | ||
'{a: a, b: b, c: c}.*', | ||
{'c': 'c', 'b': 'b', 'a': 'a', 'd': 'd'}, | ||
options=jmespath.Options(dict_cls=OrderedDict)) | ||
self.assertEqual(result, ['a', 'b', 'c']) |