Skip to content

Commit c322ba3

Browse files
add encoder for list when using native types
1 parent 06f493b commit c322ba3

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

snowfakery/data_generator_runtime_object_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# objects that represent the hierarchy of a data generator.
2020
# roughly similar to the YAML structure but with domain-specific objects
2121
Definition = Union["ObjectTemplate", "SimpleValue", "StructuredValue"]
22-
FieldValue = Union[None, Scalar, ObjectRow, tuple, PluginResult, ObjectReference]
22+
FieldValue = Union[None, Scalar, ObjectRow, tuple, PluginResult, ObjectReference, list]
2323

2424

2525
class FieldDefinition(ABC):

snowfakery/output_streams.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class OutputStream(ABC):
6161
type(None): noop,
6262
bool: int,
6363
Decimal: str,
64+
list: lambda data_list: json.dumps(data_list),
6465
}
6566
uses_folder = False
6667
uses_path = False

tests/test_json.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- snowfakery_version: 3
2+
- object: SomeObject
3+
fields:
4+
formula_field_example: ${{fake.json(data_columns={'Spec':'@1.0.1', 'ID':'pyint','Details':{'Name':'name', 'Address':'address'}}, num_rows=10)}}

0 commit comments

Comments
 (0)