From 5988f36102face30f955d616df8b8fb052e814e9 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 7 Jun 2016 11:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84JSON?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=9D=9E=E6=95=B0=E7=BB=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 38a4935c..7f23f479 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -321,11 +321,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $value = json_encode($value, JSON_FORCE_OBJECT); } break; - case 'json': + case 'array': - if (is_array($value)) { - $value = json_encode($value, JSON_UNESCAPED_UNICODE); - } + $value = (array) $value; + case 'json': + $value = json_encode($value, JSON_UNESCAPED_UNICODE); + break; } return $value;