Laravel 5.8。保存到Mysql后,为什么在json列中键的顺序会更改

时间:2019-05-15 09:35:14

标签: mysql laravel-5

为什么在JSON列中保存到Mysql时,键的顺序会更改? 这是创建用户时按键的顺序:

$user->emailNotifications()->create([
            'settings' =>
                [
                    "orders"        => [
                        "paid"    => false,
                        "snipped" => false,
                    ],
                    "store_actions" => [
                        "added"               => false,
                        "deleted"             => false,
                        "transferred_license" => false,
                    ],
                    "billing"       => [
                        "changed_cycle"  => false,
                        "failed_payment" => false,
                    ],
                    "products"      => [
                        "deactivated" => false,
                    ],
                ],
        ]);

但以不同的顺序存储在数据库中:

"orders": {
  "paid": true,
  "snipped": true
},
"billing": {
  "changed_cycle": false,
  "failed_payment": false
},
"products": {
  "deactivated": false
},
"store_actions": {
  "added": false,
  "deleted": false,
  "transferred_license": false
}

可能是什么问题?

0 个答案:

没有答案