8
8

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.

node.js + expressでjsonが文字化け

Last updated at Posted at 2014-09-19

レスポンスのjsonが文字化けした時の対応

今回は面倒な変換とかいらなかった

res.charsetに設定

res.charset = 'utf-8'
res.json(results);

結果はorz

{"title":"J笘�笘�笘�"}

ヘッダーに設定する

res.header("Content-Type", "application/json; charset=utf-8");
res.json(results);

いけたよ!

{"title":"J★A★C★K"}
8
8
1

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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?