VBA to convert Excel to JSON [or CSV to JSON]

writetoevv

Board Regular
Joined
Mar 9, 2012
Messages
71
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi Friends

Would you please help to create below JSON file format from Excel/CSV via VBA.

a) Excel Snapshot with input data is provided for your reference.

b) Here is final sample output of JSON file for your reference

JSON:
[
   {
      "question":"150/3",
      "question_title":"",
      "question_image":"",
      "wrong_answer_text":"",
      "right_answer_text":"",
      "question_hint":"",
      "explanation":"",
      "user_explanation":"",
      "type":"radio",
      "published":"1",
      "create_date":"0000-00-00 00:00:00",
      "not_influence_to_score":"",
      "weight":"1",
      "options":"",
      "category":"Uncategorized",
      "answers":[
         {
            "answer":"60",
            "image":"",
            "correct":"0",
            "ordering":"1",
            "weight":"1",
            "keyword":"A",
            "placeholder":""
         },
         {
            "answer":"50",
            "image":"",
            "correct":"1",
            "ordering":"2",
            "weight":"2",
            "keyword":"A",
            "placeholder":""
         },
         {
            "answer":"100",
            "image":"",
            "correct":"0",
            "ordering":"3",
            "weight":"1",
            "keyword":"A",
            "placeholder":""
         }
      ]
   },
   {
      "question":"10+20",
      "question_title":"",
      "question_image":"",
      "wrong_answer_text":"",
      "right_answer_text":"",
      "question_hint":"",
      "explanation":"",
      "user_explanation":"",
      "type":"radio",
      "published":"1",
      "create_date":"0000-00-00 00:00:00",
      "not_influence_to_score":"",
      "weight":"1",
      "options":"",
      "category":"Uncategorized",
      "answers":[
         {
            "answer":"30",
            "image":"",
            "correct":"1",
            "ordering":"1",
            "weight":"2",
            "keyword":"A",
            "placeholder":""
         },
         {
            "answer":"40",
            "image":"",
            "correct":"0",
            "ordering":"2",
            "weight":"1",
            "keyword":"A",
            "placeholder":""
         },
         {
            "answer":"50",
            "image":"",
            "correct":"0",
            "ordering":"3",
            "weight":"1",
            "keyword":"A",
            "placeholder":""
         }
      ]
   }
]

Thanks.
 

Attachments

  • mrexcel snapshot.jpg
    mrexcel snapshot.jpg
    69.3 KB · Views: 14
Last edited by a moderator:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Any Help on this is highly Appreciated..

Fyi, Need any input please reply back.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top