summaryrefslogtreecommitdiff
path: root/jq.pyx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-05-01 17:54:08 +0100
committerMichael Williamson <mike@zwobble.org>2023-05-01 17:54:08 +0100
commit69804ec9a5ffdf742ed6ca868062f3c8fa67e11f (patch)
tree82a84058e58ba310aff3a57b254b3970f0d81634 /jq.pyx
parent1bf642c6a1ef244131d37b9764a7493c8e1c5648 (diff)
Support multiple input values
Diffstat (limited to 'jq.pyx')
-rw-r--r--jq.pyx8
1 files changed, 8 insertions, 0 deletions
diff --git a/jq.pyx b/jq.pyx
index a280687..15882ad 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -1,3 +1,4 @@
+import io
import json
import threading
@@ -255,6 +256,13 @@ cdef class _Program(object):
def input_value(self, value):
return self.input_text(json.dumps(value))
+ def input_values(self, values):
+ fileobj = io.StringIO()
+ for value in values:
+ json.dump(value, fileobj)
+ fileobj.write("\n")
+ return self.input_text(fileobj.getvalue())
+
def input_text(self, text):
return _ProgramWithInput(self._jq_state_pool, text.encode("utf8"))