fix: return value if JSON attribute is invalid

This commit is contained in:
Marc 2023-04-05 18:58:15 +02:00
parent 74799c27b4
commit 3ad1e1f7b5

View File

@ -8,7 +8,12 @@ class JSONField extends Field {
} }
fromDB(value) { fromDB(value) {
try {
if (typeof value === 'string') return JSON.parse(value); if (typeof value === 'string') return JSON.parse(value);
} catch (error) {
// Just return the value if it's not a valid JSON string
return value;
}
return value; return value;
} }
} }