Sometimes you might have all your data inside a Google Sheet, but to make it useful for a tool that you're working on you might have to convert it into a JSON file or JavaScript array. This script does just that. 

It takes any data from your sheet and will add a JSON file to your Google Drive.

To get started, make a copy of the above Google Sheet and open your script editor by going to "Tools" -> "Script editor".

Step 1 - Name the JSON file

Change the name from "NameOfTheFile" to something of your choice. That way it'll b easier to spot inside your Google Drive.

DriveApp.createFile("NameOfTheFile.json", result, MimeType.PLAIN_TEXT);

Step 2 - Check JSON output

The output of this script will be as follows:

{"School" : "A", "Class" : "1"}, 
{"School" : "B", "Class" : "2"}, 
{"School" : "C", "Class" : "3"}, 
{"School" : "D", "Class" : "4"}, 
{"School" : "E", "Class" : "5"}

In case you'd like to group headings or manipulate the script in a different way then please let me know and I'll try to help out.

Step 3 - Run script

By clicking on "run" the JSONconverter function will start and add the JSON file to your Google Drive. Simply search for the file and you should have your data nicely formatted. 

Let me know if this was useful & let's connect on     or