diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-06-19 10:41:28 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-06-19 10:41:28 +0100 |
| commit | 20a73a5f293492b9490f4fec3a060cc173c879f8 (patch) | |
| tree | fa66893a0db7e2d17a46856b72b77fe5cab39995 | |
| parent | dffec2542092df6f207300d5aaca49fcfe7be486 (diff) | |
Add transform_json method
| -rw-r--r-- | jq.pyx | 3 | ||||
| -rw-r--r-- | tests/jq_tests.py | 10 |
2 files changed, 12 insertions, 1 deletions
@@ -41,6 +41,9 @@ class _Program(object): def transform_string(self, input): return _Result(_string_to_strings(self._program, input)) + + def transform_json(self, input): + return _Result(_string_to_strings(self._program, json.dumps(input))) class _Result(object): diff --git a/tests/jq_tests.py b/tests/jq_tests.py index 348727c..6e9066b 100644 --- a/tests/jq_tests.py +++ b/tests/jq_tests.py @@ -4,7 +4,7 @@ from jq import jq @istest -def dot_operator_does_nothing(): +def dot_operator_does_nothing_to_string_input(): assert_equal( "42", str(jq(".").transform_string("42")) @@ -12,6 +12,14 @@ def dot_operator_does_nothing(): @istest +def dot_operator_does_nothing_to_json_input(): + assert_equal( + '"42"', + str(jq(".").transform_json("42")) + ) + + +@istest def can_add_one_to_each_element_of_an_array(): assert_equal( "[2,3,4]", |
