doushi9376 2015-02-09 14:39
浏览 50
已采纳

我们如何从Linkedin Share API准备“有效的JSON”

Recently, from our log, we saw this:

httpRes status received 400 Bad Request for this linkedinToken AQUz3sCODu312rHNtNfuns3awy0xoUxxxxxxxxxxx.
 With Request: {"content":{"submitted-url":"http://mpg.smh.re/2Ra","title":"Gestionnaire sinistre H/F − Belgique ","description":"Responsable de la gestion de dossiers sinistres dans leur intégralité,
 vous serez en contact avec de nombreux interlocuteurs (compagnies 
d’assurances, clients et bureaux locaux).","submitted-image-url":"http://www.morganphilipsexecutivesearch.com/wp-content/uploads/2014/09/fyte-smarpshare.jpg"},"visibility":{"code":"anyone"},"comment":"FYTE, cabinet de recrutement spécialisé recrute pour l’un de ses clients situé en Belgique un Gestionnaire sinistre H/F."}.
 Response body: {
  "errorCode": 0,
  "message": "Couldn't parse Json body: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value
 at [Source: java.io.StringReader@42ea5bc1; line: 1, column: 187]",
  "requestId": "0GYQWP14U9",
  "status": 400,
  "timestamp": 1423490252325
}

```

LinkedIn API said that it couldn't parse JSON body. Our doubt is that either character "é" or "’" is not handled by JAVA JSON parser.

My question is that is there any other special/unicode characters that we should be aware of? Because this JSON body was marshaled by Go's built-in.

UPDATE: I recently discovered that "line feed" ("CTRL-CHAR, code 10") is the key to this issue. "Line feed" character appears after "...leur intégralité,". My question now is that why doesn't Go built-in JSON marshaller handle that

  • 写回答

1条回答 默认 最新

  • drbd65446 2015-02-09 14:50
    关注

    JSON can cope with Unicode characters ... provided that they are properly encoded.

    However the error message says:

    Illegal unquoted character ((CTRL-CHAR, code 10))
    

    which seems to be saying that you have a control character in the JSON. The JSON syntax states that unescaped control characters are not permitted in strings.

    Now if we assume that 10 is decimal, then it is a newline character. So I would look for a raw newline within the JSON about 187 characters from the start.


    My question now is that why doesn't Go built-in JSON marshaller handle that.

    Two possibilities:

    • it is a bug, or
    • you are not using it correctly.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题