Sails.js / Nodejs / Json支持emojis

时间:2016-12-27 23:09:45

标签: json node.js rest api sails.js

有没有办法在Sails REST API上使用表情符号?我有我的表与utf8mb4_unicode_ci和手动我可以正确存储表情符号。但是在网络视图和api响应中,它显示为问号“?”。

请。欢迎任何提示。

谢谢

更多信息:

例如,我用这个

命中了api
{
    "name": "hello",
    "body": "Testing on node  v6.9  x4",
    "label": "info",
    "user": 1
}

但回复是:

{
  "name": "hello",
  "body": "Testing on node  v6.9 ???? x4",
  "label": "info",
  "thanks": 0,
  "notUseful": 0,
  "createdAt": "2016-12-28T15:30:26.000Z",
  "updatedAt": "2016-12-28T15:30:26.000Z",
  "id": 105,
  "user": 1,
  "topic": null
}

1 个答案:

答案 0 :(得分:3)

您是否已在charsetcollation中将config/connections.jsconfig/local.js设置添加到MySQL配置中?

someMysqlServer: {
  adapter: 'sails-mysql',
  // other settings...
  charset: 'utf8mb4',
  collation: 'utf8mb4_unicode_ci',
}