Skip to content

Commit 8348456

Browse files
feat: The json module is now avaiable to stream maps (#2531)
* Add json function to CustomStreamMap This allows using `json.loads()` and `json.dumps()` to convert fields between text and json representations. * docs: Add json function to Stream Maps * Update docs/stream_maps.md * Update docs/stream_maps.md * Update docs/stream_maps.md * Update docs/stream_maps.md --------- Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com>
1 parent 7a3f42a commit 8348456

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/stream_maps.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ can be referenced directly by mapping expressions.
234234
`hashlib.md5(<input>.encode("utf-8")).hexdigest()`.
235235
- `datetime` - This is the datetime module object from the Python standard library. You can access
236236
datetime.datetime, datetime.timedelta, etc.
237+
- [`json`](inv:python:py:module:#json) - This is the json module object from the Python standard
238+
library. Primarily used for calling [`json.dumps()`](inv:python:py:function:#json.dumps)
239+
and [`json.loads()`](inv:python:py:function:#json.loads).
237240

238241
#### Built-in Variable Names
239242

singer_sdk/mapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import fnmatch
1313
import hashlib
1414
import importlib.util
15+
import json
1516
import logging
1617
import typing as t
1718

@@ -306,6 +307,7 @@ def functions(self) -> dict[str, t.Callable]:
306307
funcs["md5"] = md5
307308
funcs["datetime"] = datetime
308309
funcs["bool"] = bool
310+
funcs["json"] = json
309311
return funcs
310312

311313
def _eval(

0 commit comments

Comments
 (0)