Skip to content

Commit effa6bd

Browse files
authored
decode json (#3298)
* decode json * openapi
1 parent 7d53336 commit effa6bd

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

docs/source/openapi.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@
372372
{
373373
"$ref": "#/components/schemas/TranslationVariableLanguagesFeature"
374374
},
375+
{
376+
"$ref": "#/components/schemas/JsonFeature"
377+
},
375378
{
376379
"$ref": "#/components/schemas/SequenceFeature"
377380
},
@@ -510,6 +513,19 @@
510513
}
511514
}
512515
},
516+
"JsonFeature": {
517+
"type": "object",
518+
"required": ["_type"],
519+
"properties": {
520+
"_type": {
521+
"type": "string",
522+
"enum": ["Json"]
523+
},
524+
"decode": {
525+
"type": "boolean"
526+
}
527+
}
528+
},
513529
"SequenceFeature": {
514530
"type": "object",
515531
"required": ["_type", "feature"],
@@ -669,6 +685,9 @@
669685
{
670686
"$ref": "#/components/schemas/TranslationVariableLanguagesCell"
671687
},
688+
{
689+
"$ref": "#/components/schemas/JsonCell"
690+
},
672691
{
673692
"$ref": "#/components/schemas/SequenceCell"
674693
},
@@ -766,6 +785,19 @@
766785
}
767786
}
768787
},
788+
"JsonCell": {
789+
"oneOf": [
790+
{
791+
"$ref": "#/components/schemas/ValueCell"
792+
},
793+
{
794+
"$ref": "#/components/schemas/ListCell"
795+
},
796+
{
797+
"$ref": "#/components/schemas/DictCell"
798+
}
799+
]
800+
},
769801
"SequenceCell": {
770802
"oneOf": [
771803
{

libs/libcommon/src/libcommon/viewer_utils/features.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ def get_cell_value(
445445
storage_client=storage_client,
446446
json_path=json_path,
447447
)
448+
elif isinstance(fieldType, Json):
449+
return fieldType.decode_example(cell) if fieldType.decode else cell
448450
elif isinstance(fieldType, list):
449451
if not isinstance(cell, list):
450452
raise TypeError("list cell must be a list.")
@@ -535,7 +537,6 @@ def get_cell_value(
535537
Array5D,
536538
Translation,
537539
TranslationVariableLanguages,
538-
Json,
539540
),
540541
):
541542
return cell

0 commit comments

Comments
 (0)