mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 00:46:57 +08:00
fix parse_json_fields
This commit is contained in:
@@ -69,11 +69,13 @@ class Subscribe(BaseModel):
|
|||||||
@validator('sites', pre=True)
|
@validator('sites', pre=True)
|
||||||
def parse_json_fields(cls, value):
|
def parse_json_fields(cls, value):
|
||||||
if value:
|
if value:
|
||||||
|
if isinstance(value, str):
|
||||||
try:
|
try:
|
||||||
return json.loads(value)
|
return json.loads(value)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise ValueError(f"Invalid JSON string: {value}")
|
return []
|
||||||
return {}
|
return value
|
||||||
|
return []
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|||||||
+3
-1
@@ -26,10 +26,12 @@ class UserBase(BaseModel):
|
|||||||
@validator('permissions', 'settings', pre=True)
|
@validator('permissions', 'settings', pre=True)
|
||||||
def parse_json_fields(cls, value):
|
def parse_json_fields(cls, value):
|
||||||
if value:
|
if value:
|
||||||
|
if isinstance(value, str):
|
||||||
try:
|
try:
|
||||||
return json.loads(value)
|
return json.loads(value)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise ValueError(f"Invalid JSON string: {value}")
|
return {}
|
||||||
|
return value
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
Reference in New Issue
Block a user