{"id":235,"date":"2017-03-04T08:00:40","date_gmt":"2017-03-04T05:00:40","guid":{"rendered":"https:\/\/zakirov.net\/blog\/?p=235"},"modified":"2017-03-04T08:49:58","modified_gmt":"2017-03-04T05:49:58","slug":"doctrine-json_array-unescaped","status":"publish","type":"post","link":"https:\/\/zakirov.net\/blog\/2017\/03\/04\/doctrine-json_array-unescaped\/","title":{"rendered":"Doctrine: \u0442\u0438\u043f json_array, \u0440\u0443\u0441\u0441\u043a\u0438\u0435 \u0431\u0443\u043a\u0432\u044b \u0438 JSON_UNESCAPED_UNICODE"},"content":{"rendered":"<p>\u0412 Doctrine \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u044b\u043d\u043d\u044b\u0445 (\u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445) &#8212; <strong>json_array<\/strong>. \u041d\u043e \u0443 \u043d\u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0439, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u0441\u0442\u0440\u043e\u043a\u0430 &#171;\u041f\u0440\u0438\u0432\u0435\u0442&#187; \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &#171;\\u041f\\u0440\\u0438\\u0432\\u0435\\u0442&#187;, \u0447\u0442\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0442\u0430\u0431\u043b\u0438\u0446.<br \/>\n<!--more--><\/p>\n<p>\u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Doctrine \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 PHP-\u0444\u0443\u043d\u043a\u0446\u0438\u044e json_encode() \u0431\u0435\u0437 \u043e\u043f\u0446\u0438\u0439. \u0410 \u0432 PHP, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 5.4, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043e\u043f\u0446\u0438\u044f <strong>JSON_UNESCAPED_UNICODE<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0432 Doctrine \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0442\u0438\u043f\u043e\u043c json_array. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 <strong>Symfony<\/strong>.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <strong>src\/AppBundle\/Doctrine\/Types\/JsonArrayType.php<\/strong> (\u043f\u0443\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 &#8212; \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438) \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre class=\"lang:php\">\r\nnamespace AppBundle\\Doctrine\\Types;\r\n\r\nuse Doctrine\\DBAL\\Platforms\\AbstractPlatform;\r\nuse Doctrine\\DBAL\\Types\\JsonArrayType as BaseJsonArrayType;\r\n\r\nclass JsonArrayType extends BaseJsonArrayType\r\n{\r\n    public function convertToDatabaseValue($value, AbstractPlatform $platform)\r\n    {\r\n        if (null === $value) {\r\n            return null;\r\n        }\r\n\r\n        return json_encode($value, JSON_UNESCAPED_UNICODE);\r\n    }\r\n}<\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (<strong>app\/config\/config.yml<\/strong>) \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 doctrine \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 json_array:<\/p>\n<pre class=\"lang:yaml\" >\r\ndoctrine:\r\n    dbal:\r\n        types:\r\n            json_array: AppBundle\\Doctrine\\Types\\JsonArrayType\r\n<\/pre>\n<p>\u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0431\u0430\u0437\u0443 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c UTF-8.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, <a href=\"\/blog\/2017\/03\/04\/doctrine-tinyint\/\">\u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f tinyint \u0432 Doctrine<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 Doctrine \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u044b\u043d\u043d\u044b\u0445 (\u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445) &#8212; json_array. \u041d\u043e \u0443 \u043d\u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0439, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0440\u0443\u0441\u0441\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0431\u0430\u0439\u0442\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u0441\u0442\u0440\u043e\u043a\u0430 &#171;\u041f\u0440\u0438\u0432\u0435\u0442&#187; \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &#171;\\u041f\\u0440\\u0438\\u0432\\u0435\\u0442&#187;, \u0447\u0442\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,3,20,12,9],"tags":[],"_links":{"self":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/235"}],"collection":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":9,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}