MCPcopy Index your code
hub / github.com/pathwaycom/pathway / as_bool

Method as_bool

python/pathway/internals/json.py:173–194  ·  view source on GitHub ↗

Returns Json value as a float if possible. Example: >>> import pathway as pw >>> import sys; sys.modules[__name__].pw = pw # NODOCS >>> class InputSchema(pw.Schema): ... data: pw.Json ... >>> @pw.udf ... def extract(data: pw.Json)

(self)

Source from the content-addressed store, hash-verified

171 return self._as_type(float)
172
173 def as_bool(self) -> bool:
174 """Returns Json value as a float if possible.
175
176 Example:
177
178 >>> import pathway as pw
179 >>> import sys; sys.modules[__name__].pw = pw # NODOCS
180 >>> class InputSchema(pw.Schema):
181 ... data: pw.Json
182 ...
183 >>> @pw.udf
184 ... def extract(data: pw.Json) -> bool:
185 ... return data["value"].as_bool()
186 ...
187 >>> table = pw.debug.table_from_rows(schema=InputSchema, rows=[({"value": True},)])
188 >>> result = table.select(result=extract(pw.this.data))
189 >>> pw.debug.compute_and_print(result, include_id=False)
190 result
191 True
192 """
193
194 return self._as_type(bool)
195
196 def as_list(self) -> list:
197 """Returns Json value as a list if possible.

Callers 4

_convert_from_jsonFunction · 0.45
test_json_inputFunction · 0.45
test_convertFunction · 0.45

Calls 1

_as_typeMethod · 0.95

Tested by 3

test_json_inputFunction · 0.36
test_convertFunction · 0.36