diff options
| author | Michael Williamson <mike@zwobble.org> | 2020-05-02 11:12:18 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2020-05-02 11:12:18 +0100 |
| commit | e7471d1a36ab71abdab4d1f3cd8f246108b42eb6 (patch) | |
| tree | 65f1d59bb8a3761c0c4fd3eec75ee4980e1eb60c /README.rst | |
| parent | fa7399eb01fce0a81e617af03d752527093e7d72 (diff) | |
Add convenience functions
Diffstat (limited to 'README.rst')
| -rw-r--r-- | README.rst | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -110,6 +110,16 @@ Call ``iter()`` to get all of the output elements as an iterator: assert next(iterator, None) == 4 assert next(iterator, None) == None +Convenience functions are available to get the output for a program and input in one call: + +.. code-block:: python + + assert jq.first(".[] + 1", [1, 2, 3]) == 2 + assert jq.first(".[] + 1", text="[1, 2, 3]") == 2 + assert jq.text(".[] + 1", [1, 2, 3]) == "2\n3\n4" + assert jq.all(".[] + 1", [1, 2, 3]) == [2, 3, 4] + assert list(jq.iter(".[] + 1", [1, 2, 3])) == [2, 3, 4] + The original program string is available on a compiled program as the ``program_string`` attribute: .. code-block:: python |
