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)
| 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. |