summaryrefslogtreecommitdiff
path: root/jq.pyx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-27 14:56:05 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-27 14:56:05 +0000
commit72f52a18069c2a04b9cb8bbe6f5185fe4c384be1 (patch)
tree86e423c0b1592b66d8954cbb8de413f636c9017e /jq.pyx
parentc09350f5016796ee76d2e43f174cce2fdb672ddd (diff)
Replace raw_input with the text argument
Diffstat (limited to 'jq.pyx')
-rw-r--r--jq.pyx11
1 files changed, 9 insertions, 2 deletions
diff --git a/jq.pyx b/jq.pyx
index 980662d..cec6e69 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -100,6 +100,11 @@ cdef class _ErrorStore(object):
self._errors = []
+class EmptyValue(object):
+ pass
+
+_NO_VALUE = EmptyValue()
+
cdef class _Program(object):
cdef jq_state* _jq
cdef _ErrorStore _error_store
@@ -107,8 +112,10 @@ cdef class _Program(object):
def __dealloc__(self):
jq_teardown(&self._jq)
- def transform(self, input, raw_input=False, raw_output=False, multiple_output=False):
- string_input = input if raw_input else json.dumps(input)
+ def transform(self, value=_NO_VALUE, text=_NO_VALUE, raw_output=False, multiple_output=False):
+ if (value is _NO_VALUE) == (text is _NO_VALUE):
+ raise ValueError("Either the value or text argument should be set")
+ string_input = text if text is not _NO_VALUE else json.dumps(value)
bytes_input = string_input.encode("utf8")
self._error_store.clear()