Skip to content

Commit d951d14

Browse files
Adding support for json_to_cel() to be able to convert tuple objects
1 parent ebbdf62 commit d951d14

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/celpy/adapter.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def json_to_cel(document: JSON) -> celtypes.Value:
121121
return celtypes.StringType(document)
122122
elif document is None:
123123
return None
124-
elif isinstance(document, List):
124+
elif isinstance(document, (tuple, List)):
125125
return celtypes.ListType(
126126
[json_to_cel(item) for item in document]
127127
)

‎tests/test_adapter.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def test_json_to_cel():
3535
celpy.celtypes.StringType("world!"),
3636
]
3737
)
38+
assert celpy.adapter.json_to_cel(tuple(["Hello", "world!"])) == celpy.celtypes.ListType(
39+
[
40+
celpy.celtypes.StringType("Hello"),
41+
celpy.celtypes.StringType("world!"),
42+
]
43+
)
3844
assert celpy.adapter.json_to_cel({"Hello": "world!"}) == celpy.celtypes.MapType(
3945
{
4046
celpy.celtypes.StringType("Hello"):

0 commit comments

Comments
 (0)