75
62

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

日本語をunicode変換しないでjson_encodeする方法

Posted at

日本語を含む配列をjson_encodeすると、日本語部分が文字コードで表示されてしまう。
そんな場合は、json_encodeの第二引数にJSON_UNESCAPED_SLASESを入れると日本語でjsonを返してくれる。(バージョン5.4.0以上のみ)

$array = array('key1': 'あああ', 'key2': 'いいい');
$jp_json = json_encode( $array , JSON_UNESCAPED_UNICODE) ;

参考: https://syncer.jp/how-to-use-json

75
62
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
75
62

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?