diff --git a/services/nginx/app/classes/object_property.php b/services/nginx/app/classes/object_property.php index 5882e976..f48ef872 100644 --- a/services/nginx/app/classes/object_property.php +++ b/services/nginx/app/classes/object_property.php @@ -51,7 +51,7 @@ class object_property throw new \InvalidArgumentException("Table or column cannot be empty"); } // Check if the type is valid - if (!in_array($this->type, ['int', 'varchar', 'text', 'date', 'datetime', 'string', 'timestamp', 'boolean', 'bool', 'float'])) { + if (!in_array($this->type, ['int', 'varchar', 'text', 'date', 'datetime', 'string', 'timestamp', 'boolean', 'bool', 'float', 'json'])) { throw new \InvalidArgumentException("Invalid type: $this->type"); } $sql = "SELECT $this->column FROM $this->table WHERE id = $this->id"; @@ -60,6 +60,11 @@ class object_property if (empty($row)) { throw new \RuntimeException("No record found for column '$this->column' in table '$this->table' with ID $this->id"); } + // If the type is set to json, decode it. + $value = $row[$this->column]; + if ($this->type === 'json' && $value !== null) { + return json_decode($value, true); + } return $row[$this->column]; }