We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c9031f commit ddae72dCopy full SHA for ddae72d
src/model/type/Json.php
@@ -20,12 +20,14 @@ public static function from(mixed $value, Modelable $model)
20
21
public function data($data, ?bool $assoc)
22
{
23
- if (is_string($data) && json_validate($data)) {
24
- $data = json_decode($data, $assoc);
25
- } elseif (empty($data)) {
26
- $data = [];
+ if (is_string($data)) {
+ $this->data = json_decode($data, $assoc);
+ if (json_last_error() !== JSON_ERROR_NONE) {
+ $this->data = [$data];
27
+ }
28
+ return;
29
}
- $this->data = is_string($data) ? [$data] : $data;
30
+ $this->data = empty($data) ? [] : $data;
31
32
33
public function value()
0 commit comments