0

Possible Duplicate:
Excel to various JSON objects

I've started to use SlickQuiz which is a jQuery plugin. In there, the questions are added to the quiz using a JSON object. See an example here. Rather than modify this by hand each time I generate I new quiz, is there a way to generate this from say an Excel table or similar?

If so, then firstly, I can't understand what the structure of the (Excel) table would need to be like to get the nested structure in JSON. Can you help? And, is there a good existing serialiser (right term?) out there?

Open to suggestions...

Community
  • 1
  • 1
SimpleOne
  • 1,066
  • 3
  • 12
  • 29
  • You might [parse a CSV file](http://stackoverflow.com/questions/7431268/how-read-data-from-csv-file-using-javascript/7431565) exported from that Excel table. – Blazemonger May 29 '12 at 12:57
  • OK, thanks. Can you help with the format of the data table so I end up with the right output per the example link in the question – SimpleOne May 29 '12 at 13:14

1 Answers1

0

If your structure is not too deeply nested, you could write the structure out, and reserve a limited number of columns for answers (for example 4). You Excel file would have two sheets: one with the contents of info in a simple two column list, and one with the questions, having the following column names:

  • questions.q
  • questions.a[0].option
  • questions.a[0].correct
  • questions.a[1].option
  • questions.a[1].correct
  • questions.a[2].option
  • questions.a[2].correct
  • questions.a[3].option
  • questions.a[3].correct
  • questions.correct
  • questions.incorrect

If you keep the column names corresponding with the path of the fields as they will appear in the JSON structure, it will be quite easy to parse the table structure into JSON and back.

However, it will be a cumbersome solution anyway. Can't you edit your JSON structure using a JSON editor like http://jsoneditoronline.org? Or implement a simple admin page on your website where you can edit the quiz? that will be quite easy to make using the library from jsoneditoronline: https://github.com/josdejong/jsoneditoronline/wiki

Jos de Jong
  • 6,602
  • 3
  • 38
  • 58