从POST的主体解析JSON

时间:2015-07-14 16:50:28

标签: javascript json post

我正在使用cameratag.com在我的网站上录制视频。该服务可以向我的服务器发送JSON响应,以便将数据保存到我的数据库中。但是我不知道如何继续这里:

文档声明请注意,JSON repsonse在POST的主体中传递,而不是作为表单参数传递。以下是如何在ruby中解析响应的示例:

data = JSON.parse(request.raw_post)
video_uuid = data["uuid"]

但我不知道如何获取有关JavaScript的数据。

POST示例:

    {
  "uuid": "00012710-4b65-0131-ffe6-22000a499ea4",
  "camera_uuid": "98373a20-79ee-0130-3e42-1231390fcc11",
  "created_at": "2013-12-20T05:25:02.000Z",
  "percent_complete": 100,
  "short_code": "KKtB4Q",
  "metadata": {
  },
  "state": "published",
  "recorded_from": "http://singwho.com",
  "publish_type": null,
  "formats": [
    {
      "name": "720p",
      "width": 1280,
      "height": 720,
      "video_url": "https://cameratag.com/videos/00012710-4b65-0131-ffe6-22000a499ea4/720p/mp4.mp4",
      "flv_url": null,
      "flv_stream": null,
      "mp4_url": "https://cameratag.com/videos/00012710-4b65-0131-ffe6-22000a499ea4/720p/mp4.mp4",
      "mp4_stream": "rtmp://sa0xpxq1vz1ri.cloudfront.net/cfx/st&mp4:98373a20-79ee-0130-3e42-1231390fcc11/00012710-4b65-0131-ffe6-22000a499ea4_720p.mp4?Expires=1436892019&Signature=OhVUCK0GGLSNiaO~2MVp03YPmb9xcYQnbKMFfRaZsVwerQtdwF9Kcf~fKyg1vQH9HYZdoeADXmszRxpxi2Np6FH8YloVFjPFjOkBPJEQ0Z4IWh6hKbWD8hL861kSFKKrEBNgxSJeTG1F8XpXMISRTYhZ11G3FRoZwg42CwKIP0w0LqQnIwz5Hi0yw35AgQRn1zBBEYqBBkR~QhW9OyLkU5K15b0-RnOH~EmDXUzGJQHBkGgSyCXY0D41Ak~~Co0ocqJD9Phe2ZfA7Qy-JHWwLHr66bQuP3g~E3CgGo0-vtCphnWrxDTxgNezP~SRI~BWrvlljVwPWF5LZXy5ByTf1w__&Key-Pair-Id=APKAIYEVFIMHKY7YWGKA",
      "webm_url": "https://cameratag.com/videos/00012710-4b65-0131-ffe6-22000a499ea4/720p/webm.webm",
      "webm_stream": "rtmp://sa0xpxq1vz1ri.cloudfront.net/cfx/st&webm:98373a20-79ee-0130-3e42-1231390fcc11/00012710-4b65-0131-ffe6-22000a499ea4_720p.webm?Expires=1436892019&Signature=PDL1Bubk6QkW-kNRm9GhHFAxdNdA57S6S0YM1hgM5SuHYULS84dOXcYz~LjPFd-bjgOJDWdEONfv60SqcFkN0cy93BHbs1Pk3bNLW-y0VFnMzIuT8QmEWuO60Yt8Bg7IJdvtph3Jmtolay9VFL~ZPTcX1ljhPKbBiZzIhuzfMtBChQrGXAb19jG6Rv8bxrST8aR~EuC31XFQ4LlN-L8G~pkf9s-DOquNvYUnkv-0hIyiDHG4gZZKurNYyz8ZVZRh0ZKTby2C~dDIiaKskthVsmfnRIa9ADFwywDCcI7y5nUN6yVpISuRpYqoUmpbFiI3Df84ZYyXaa6vhfQu1U3CGw__&Key-Pair-Id=APKAIYEVFIMHKY7YWGKA",
      "thumbnail_url": "https://cameratag.com/videos/00012710-4b65-0131-ffe6-22000a499ea4/720p/thumb.png",
      "small_thumbnail_url": "https://cameratag.com/videos/00012710-4b65-0131-ffe6-22000a499ea4/720p/small_thumb.png",
      "state": "COMPLETED",
      "completed_at": "2013-12-20T05:30:12.000Z",
      "length": 195
    }
  ],
  "plays": 0
}

0 个答案:

没有答案