mirror of
https://github.com/strapi/strapi.git
synced 2025-09-11 09:36:38 +00:00
fix: return value if JSON attribute is invalid
This commit is contained in:
parent
74799c27b4
commit
3ad1e1f7b5
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user