【发布时间】:2016-04-06 13:28:56
【问题描述】:
我正在用 JSON、jQuery 和 JavaScript 编写一个测验。
这是我的 JSON 问题:
"questions": [
{ "q": "At a birthday party you counted 120 eyes. How many people were at the party?",
"a": [
{"option": "240", "correct": false},
{"option": "60", "correct": true},
{"option": "120", "correct": false},
{"option": "30", "correct": false} // no comma here
],
如何在问题中添加图片。这是正确的语法吗?
I have a folder called img
“q”: "At a birthday party you counted 120 eyes. How many people were at the party? <br> <br>" +
"<i** src="/i**/eyes.filename\">, ** denotes mg read: image source
另外,我如何将视频文件嵌入到 YouTube 中有链接的问题中?
【问题讨论】:
-
JSON 不了解图像或视频。您必须以接收者可以理解和使用的格式存储它。如果你是接收者,那就编造一些东西。
-
这根本没有帮助。
-
在什么方面没有帮助?我告诉你,没有“图像的 JSON 语法”之类的东西。你还想听什么?
-
那么,如何在 js 中为测验添加图像或视频?
-
您必须发明自己的格式。简单地将 HTML 放入字符串中(正如我认为您试图在示例中展示的那样)是一种简单而灵活的方法。但无论您选择什么,都由您来处理格式并用它做正确的事情。 JSON 没有任何魔力。
标签: javascript jquery json