2016-04-06 17 views
-3

JSON、jQuery、JavaScriptを使ってクイズをまとめています。写真とビデオをJSONクイズ形式に追加するには?

ここで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にリンクしている質問に動画ファイルを埋め込むにはどうすればよいですか?

+3

JSONは、画像や動画の知識を持っていません。受信者が理解し使用できる形式で保存する必要があります。あなたが受信機であれば、何かを作ってください。 – Biffen

+0

それは全く役に立たない。 –

+3

どのように役立つのですか?私は、「イメージ用のJSON構文」というものは存在しないと言っています。ほかに何を聞きたいですか? – Biffen

答えて

-1

これは、あなたがビデオを埋め込む方法です:

{ 
     "q": "How would you weigh on the moon compared to earth?", 
     "a": [ 
      {"option": "More", "correct": false}, 
      {"option": "The same",  "correct": false}, 
      {"option": "Less",  "correct": true}, 
      {"option": "Need more info",  "correct": false} // no comma here 
     ], 
     "correct": "<p><span>Good Job!</span> Eat your cheesy pizza, fries, nachos, and fly to the moon to be a size zero or watch this video <br> <center> <iframe width=560 height=315 src=https://www.youtube.com/embed/OIzOCvxJcSE frameborder=0 allowfullscreen></iframe> </center> </p>", 
     "incorrect": "<p><span>ERRRR!</span> Weight is determined by gravity, or how strongly gravity pulls on matter. Since the gravity on moon is weak compared to earth, you will weigh less.<br>Ready for a physics class? <center><iframe width=560 height=315 src=https://www.youtube.com/embed/OIzOCvxJcSE frameborder=0 allowfullscreen></iframe> </center> </p>" // no comma here 
    } 

これは、あなたがJSONに画像を追加する方法です:

{ 
      "q": "What is the amount of matter in an object called? <br> <img src=https://cdn.vectorstock.com/i/composite/08,88/question-weighing-scale-vector-840888.jpg/>", 
      "a": [ 
       {"option": "Weight",    "correct": false}, 
       {"option": "Density", "correct": false}, 
       {"option": "Volume",    "correct": false}, 
       {"option": "Mass", "correct": true} // no comma here 
      ], 
      //Make it select any rather than all. 
      "correct": "<p><span>Correct!</span> You like fancy words don't you?</p>", 
      "incorrect": "<p><span>Fail.</span> Sorry. You need to brush up on your physics vocabulary. Weight is a measure of how strongly gravity pulls on that matter. Density describes how compact or concentrated something is, expressed as mass per unit volume. Volume is Volume is the amount of space that comprises a length, a width and a height, occupied by an object or a material.</p>" 
     } 
+0

Biffen、多くの人が私のようなjavascriptを初めて使っています。あなたの答えをサンプルコードで説明できることを本当に期待していました。 –

+1

うーん..何?これは理にかなっていません。あなた自身の利益のために、JSON .. – Pogrindis

+0

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parseだけです。 – Pogrindis

関連する問題