Skip to content

Commit ee8035d

Browse files
authored
added prefix option
1 parent 6898e8c commit ee8035d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Preparation/JSON/Expand_Fields/manifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
"width": "ONE",
4646
"@visokiotype": "CustomBlockSchema.BooleanCustomBlockPublicOption",
4747
"defaultValue": true
48+
},
49+
{
50+
"name": "fieldPrefix",
51+
"title": "Expanded Fields Prefix",
52+
"description": "Optional",
53+
"groupTitle": null,
54+
"width": "ONE",
55+
"@visokiotype": "CustomBlockSchema.TextCustomBlockPublicOption",
56+
"mandatory": false,
57+
"defaultValue": null
4858
}
4959
],
5060
"blockOutputs": [

Preparation/JSON/Expand_Fields/script.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
# Get options
1212
jsonField = omniscope_api.get_option("jsonField")
1313
includeInput = omniscope_api.get_option("includeInput")
14+
prefix = omniscope_api.get_option("fieldPrefix")
15+
16+
if prefix is None:
17+
prefix = ""
1418

1519
# Function to parse JSON and add prefix to keys
1620
def parse_json(row, jsonField):
1721
try:
1822
json_dict = json.loads(row[jsonField])
19-
return {f"{jsonField}_{k}": v for k, v in json_dict.items()}
23+
return {f"{prefix}{k}": v for k, v in json_dict.items()}
2024
except (json.JSONDecodeError, TypeError):
2125
return {}
2226

0 commit comments

Comments
 (0)