json - yii2 Db column return Incorrect JSON
问题描述
One of my columns in my db( levels table ) has JSON type.
When I write some query like this
1) $levels = Levels::find()
->select("level_permissions")
->column();
2) $levels = Levels::find()
->select("level_permissions")
->all();
In second(2) version I will get my json string in " quotes" For example
"{\"name\":\"level_name\",\"active\":\"1\",\"level_administering_level_id\":\"1\"},\"LevelAccessPermission\":{\"31\":\"1\"}"
But in first(1) I have bug it returns
""{\"name\":\"level_name\",\"active\":\"1\",\"level_administering_level_id\":\"1\"},\"LevelAccessPermission\":{\"31\":\"1\"} ""
and when I decode it I get
array(1) { [0]=> string(584) "{"lev_name":"ssssssssss","lev_active":"1","lev_administering_level_id":"1"},"LevelAccessPermission":{"31":"1"}}"
The problem is in quotes. in second version the string is in quotes, but when I use -> column(), I have some "" empty double quotes, then my json, then empty double quotes.
Why in column case ? I get double quotes before and after json. I have it only when I use yii2 -> column().
Any advice... Do you have some bug like this? Any idea?
解决方案
推荐阅读
- python - AttributeError: 'float' 对象在 if 条件中使用 & 时没有属性 'isin'
- python-3.x - 如何识别具有此类名称的展开折叠图标:
- django-rest-framework - 错误 TemplateResponseMixin 需要“template_name”的定义或“get_template_names()”的实现
- javascript - Video.js:video.js 7.8.2 中用于测验的大按钮
- typescript - Angular 8将元素引用传递给方法
- c++ - ncurses 在后台?
- emacs - Emacs - 如何在弹丸和treemacs中自动添加新项目?
- javascript - Javascript获取回调不在循环中工作
- node.js - 当modules: false被babel设置时,nodejs如何解析import es6 module语句?
- c# - HTTPClient 返回 400 Bad Request 但 Postman 在 C# 中返回 201