{"id":42359,"date":"2023-05-16T21:26:35","date_gmt":"2023-05-16T19:26:35","guid":{"rendered":"https:\/\/blog.sheetgo.com\/?p=42359"},"modified":"2025-12-17T18:45:24","modified_gmt":"2025-12-17T17:45:24","slug":"importar-json-a-google-sheets","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/es\/blog\/google-sheets-features\/import-json-to-google-sheets\/","title":{"rendered":"Importar JSON a Google Sheets"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; da_disable_devices=&#8221;off|off|off&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221;][et_pb_row _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text module_id=&#8221;what-is-json&#8221; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h1><b>What is JSON?<\/b><\/h1>\n<p><span style=\"font-weight: 400;\">JSON stands for &#8220;JavaScript Object Notation&#8221;. It is a way to represent data in a simple, easy-to-read format that can be easily used by many programming languages.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Imagine you have a big bag of toys and you want to organize them. You could use different bags to put each kind of toy in a specific bag, like dolls in one bag, cars in another bag, and so on. In the same way, JSON helps organize data by putting similar information together.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">JSON files are like little bags of data that contain information about things like people, animals, or objects. The information inside a JSON file is organized into &#8220;key-value&#8221; pairs, which means that each piece of information has a name (the &#8220;key&#8221;) and a value.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, if we wanted to store information about a webshop, we might have a JSON file that looks like this:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.20.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8220;shoes&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;sneakers&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;colour&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;blue&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;brand&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;Nike&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;price&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">125<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">},<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;trainers&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;colour&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;white&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;brand&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;Puma&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;price&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">115<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">},<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;running_shoes&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;colour&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;yellow&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;brand&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">&#8220;Asics&#8221;<\/span><span style=\"font-weight: 400;\">,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&#8220;price&#8221;<\/span><span style=\"font-weight: 400;\">:<\/span> <span style=\"font-weight: 400;\">145<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">This JSON file contains information about the shoe section of a web shop. The first \u201ckey\u201d is the category \u201cshoes.\u201d <\/span><span style=\"font-weight: 400;\">After that,<\/span><span style=\"font-weight: 400;\"> the second \u201ckeys\u201d store the information on the types of shoes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">JSON files are useful because they are easy to read and write, and they can be used by many different programming languages. They are often used to store and share data between different applications or websites. When you want to import or export data from an <\/span><span style=\"font-weight: 400;\">API,<\/span><span style=\"font-weight: 400;\"> it\u2019s often done in JSON format.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;how-to-import-json&#8221; _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h1><b>How to import a JSON into Google Sheets<\/b><\/h1>\n<p><i><span style=\"font-weight: 400;\">Creating the result that you\u2019re looking for can be quite challenging. <\/span><\/i><i><span style=\"font-weight: 400;\">If you prefer to have the help of one of our expert consultants to complete your project, <\/span><\/i><a href=\"https:\/\/www.sheetgo.com\/contact-sales\/\" target=\"_blank\" rel=\"noopener\"><i><span style=\"font-weight: 400;\">click here<\/span><\/i><\/a><i><span style=\"font-weight: 400;\">.\u00a0<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">To start,<\/span><span style=\"font-weight: 400;\"> create a new Google Sheets by typing <\/span><a href=\"http:\/\/sheets.new\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">sheets.new<\/span><\/a><span style=\"font-weight: 400;\"> in your browser and give it a name. Open the Google Apps Script Integrated development environment (IDE) by clicking on \u201cExtensions\u201d and \u201cApps Script&#8221;. A new tab will open that looks like this.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-10.png&#8221; alt=&#8221;import json to gs 10&#8243; title_text=&#8221;import json to gs-10&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Remove the three lines of code that are there, give the project a name, and copy and paste the following code into this space.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.27.4&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]function getJson(<\/p>\n<p>fileId = &#8220;139GrQu0oEu1tWAMz5vHMjzmcClxA0FQ9&#8221;, \/\/ Get the ID of the JSON file.<\/p>\n<p>sheetName = &#8220;Sheet1&#8221; \/\/ Name of the sheet to import json<\/p>\n<p>) {<\/p>\n<p>var files = DriveApp.getFileById(fileId); \/\/ Specify which JSON to get.<\/p>\n<p>var json = JSON.parse(files.getBlob().getDataAsString()); \/\/Get the JSON information which now is a huge piece of text, and parse it to JSON format.<\/p>\n<p>var headers = [&#8220;category&#8221;, &#8220;item&#8221;, &#8220;colour&#8221;, &#8220;brand&#8221;, &#8220;price&#8221;]; \/\/ Define the headers for each column. This will be inserted in row 1.<\/p>\n<p>let values = [] \/\/ This is an empty Javascript array that you&#8217;re going to fill in line 27.<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/You&#8217;re nesting the for loops because the json file is cascading down.<\/p>\n<p>for (let category in json) {<\/p>\n<p>for (let item in json[category]) {<\/p>\n<p>values.push([category, item, json[category][item][&#8216;colour&#8217;], json[category][item][&#8216;brand&#8217;], json[category][item][&#8216;price&#8217;]])<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>var ss = SpreadsheetApp.getActiveSpreadsheet();<\/p>\n<p>var newSheet = ss.getSheetByName(sheetName);<\/p>\n<p>var dataToInsert = [headers].concat(values)\/\/ Here you push the headers into the first row and create an array.<\/p>\n<p>var range = newSheet.getRange(1, 1, dataToInsert.length, dataToInsert[0].length) \u00a0 \/\/ get a range of cells (row, column, numRows, numColumns)<\/p>\n<p>range.setValues(dataToInsert); \/\/ set the values to the range of cells<\/p>\n<p>}[\/et_pb_text][et_pb_text module_id=&#8221;running-a-test&#8221; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><b>Running a test<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">In order to test out the script for the first run<\/span><span style=\"font-weight: 400;\">, <a href=\"https:\/\/drive.google.com\/file\/d\/1xWZjGSJfarx7CsNvog0FoXVRHYVLHLNs\/view?usp=share_link\" target=\"_blank\" rel=\"noopener\">click here<\/a> to make a copy of the JSON file used for this example.<\/span><\/p>\n<h3><span style=\"font-weight: 600;\">Getting the file ID<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Now we have to get the file ID of your JSON file. Upload it to Google Drive, <\/span><span style=\"font-weight: 400;\">right-click on it, <\/span><span style=\"font-weight: 400;\">select \u201cshare\u201d and click on \u201ccopy link.\u201d Paste this link somewhere and copy the ID that comes between \u201chttps:\/\/drive.google.com\/file\/d\/\u201d and \u201c\/view?usp=sharing\u201d Paste this file ID between the double quotes of line 18.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-3.png&#8221; alt=&#8221;import json to gs 3&#8243; title_text=&#8221;import json to gs-3&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3><span style=\"font-weight: 600;\">Running the script<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Now that the correct file ID is in place and the script knows which file to <\/span><span style=\"font-weight: 400;\">grab,<\/span><span style=\"font-weight: 400;\"> let\u2019s run this script for the first time. Click on \u201cSave project\u201d and afterwards click on \u201cRun\u201d.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-8.png&#8221; alt=&#8221;import json to gs 8&#8243; title_text=&#8221;import json to gs-8&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Now Google will ask you for permission to run the script.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-9.png&#8221; alt=&#8221;import json to gs 9&#8243; title_text=&#8221;import json to gs-9&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Click on \u201cReview permissions\u201d and afterwards on \u201cAllow\u201d.\u00a0<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-6.png&#8221; alt=&#8221;import json to gs 6&#8243; title_text=&#8221;import json to gs-6&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">You might need to click one more time on \u201cRun\u201d. <\/span><span style=\"font-weight: 400;\">Otherwise, <\/span><span style=\"font-weight: 400;\">you should see that the execution has started and ended. And if we go to the spreadsheet we should now see this result. Having imported a JSON file is a nice result to see. You have arrived here because you want to import your JSON file. So now that the script is in place and working, let\u2019s modify it for your JSON file.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-5.png&#8221; alt=&#8221;import json to gs 5&#8243; title_text=&#8221;import json to gs-5&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;modifying-key-values&#8221; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2><b>Modifying the \u201ckey-values\u201d for your file<\/b><\/h2>\n<h3><span style=\"font-weight: 600;\">Finding the positions of your key values.<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">For this example we have used five keys, &#8220;category&#8221;, &#8220;item&#8221;, &#8220;color&#8221;, \u201cbrand\u201d and \u201cprice\u201d. In order to modify the script to work for your JSON file, double-click on the JSON file inside Google Drive to see the preview, and compare the keys in the example with your JSON file. Take note of which key in the example matches the position of the key in your file.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-11.png&#8221; alt=&#8221;import json to gs 11&#8243; title_text=&#8221;import json to gs-11&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3><span style=\"font-weight: 600;\">What if your JSON file has more than two cascades?<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">A JSON file has \u201ccascades\u201d, which are the indentations the values are written in. This is important to know because the script is written for a JSON file with only two cascades, but perhaps yours will have more than two.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-1.png&#8221; title_text=&#8221;import json to gs-1&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">In line 28 and 29 of the script, you can modify how many cascades you\u2019d like to look into. Because this JSON file has one main cascade with the second cascade being \u201citems\u201d we only use two \u201cfor loops\u201d. If your JSON file has more than two cascading down, you will have to change this:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.20.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">let<\/span> <span style=\"font-weight: 400;\">category<\/span> <span style=\"font-weight: 400;\">in<\/span> <span style=\"font-weight: 400;\">json)<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">let<\/span> <span style=\"font-weight: 400;\">item<\/span> <span style=\"font-weight: 400;\">in<\/span> <span style=\"font-weight: 400;\">json[category])<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">values.push(&#8230;<\/span> <span style=\"font-weight: 400;\">)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">To for example:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.20.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">let<\/span> <span style=\"font-weight: 400;\">cascade1<\/span> <span style=\"font-weight: 400;\">in<\/span> <span style=\"font-weight: 400;\">json)<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">let<\/span> <span style=\"font-weight: 400;\">cascade2<\/span> <span style=\"font-weight: 400;\">in<\/span> <span style=\"font-weight: 400;\">json[cascade1])<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">for<\/span> <span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">let<\/span> <span style=\"font-weight: 400;\">cascade3<\/span> <span style=\"font-weight: 400;\">in<\/span> <span style=\"font-weight: 400;\">json[cascade1][cascade2])<\/span> <span style=\"font-weight: 400;\">{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">values.push(&#8230;<\/span> <span style=\"font-weight: 400;\">)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}<\/span> <span style=\"font-weight: 400;\">\/\/Note the extra curly bracket for the added for loop<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3><span style=\"font-weight: 600;\">What if your JSON file has more than four categories?<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Another thing to highlight about the script is that in line 30 you see this:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.20.2&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">values.push([category,<\/span> <span style=\"font-weight: 400;\">item,<\/span> <span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;colour&#8217;<\/span><span style=\"font-weight: 400;\">],<\/span> <span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;brand&#8217;<\/span><span style=\"font-weight: 400;\">],<\/span> <span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;price&#8217;<\/span><span style=\"font-weight: 400;\">]])<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">We\u2019re pushing these values as rows into an empty array and each value that is being pushed into this array is separated with a comma. As you can see, this JSON file holds one category, \u201cshoes\u201d and there are three items, \u201csneakers\u201d, \u201ctrainers\u201d and \u201crunning_shoes\u201d. For each of these items there are three values, \u201ccolor\u201d, \u201cbrand\u201d and \u201cprice\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This is the reason why the notation of the values in this script is this way. Let\u2019s break it down quickly so you can modify it better for your JSON file.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The first value is plain and simple. <\/span><span style=\"font-weight: 400;\"><br \/><\/span><span style=\"font-weight: 400;\">\u2018category\u2019.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">As is the second value. <\/span><span style=\"font-weight: 400;\"><br \/><\/span><span style=\"font-weight: 400;\">\u2018item\u2019.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">But with the third value we have to let the script know it has to look inside the Javascript object of \u2018item\u2019 and return the value of \u2018color\u2019. For this reason the third value is written like this:<\/span><span style=\"font-weight: 400;\"><br \/><\/span><span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;colour&#8217;<\/span><span style=\"font-weight: 400;\">].<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Same with the fourth item. We look into the Javascript object of \u2018item\u2019 and return \u2018brand\u2019.<\/span><span style=\"font-weight: 400;\"><br \/><\/span><span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;brand&#8217;<\/span><span style=\"font-weight: 400;\">]<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Lastly, with the fifth item, we stay in the object of &#8216;item&#8217; and return \u2018price\u2019.<\/span><span style=\"font-weight: 400;\"><br \/><\/span><span style=\"font-weight: 400;\">json[category][item][<\/span><span style=\"font-weight: 400;\">&#8216;price&#8217;<\/span><span style=\"font-weight: 400;\">]<\/span><\/li>\n<\/ol>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3><span style=\"font-weight: 600;\">Changing the values in the script.<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To change the values in the script, go back to it and hit CTRL+F and Click on the drop down arrow to expand the search menu.<\/span><\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2023\/04\/import-json-to-gs-7.png&#8221; alt=&#8221;import json to gs 7&#8243; title_text=&#8221;import json to gs-7&#8243; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Type in your key name you want to replace in the bar below it and hit this icon to replace all instances in the script. Do this for each key name you\u2019d like to import into the Google Sheets.\u00a0<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;import-json&#8221; _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>Import JSON to Google Sheets<\/p>\n<h2\/>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><span style=\"font-weight: 400;\">Lastly, take your JSON file and hold it next to line 30 of the script. Are all the value notations in the values.push( \u2026 ) method telling the script to look in the right places? If you think so, go for it. Click on \u201cRun\u201d and see which result is created. Do you get an error message? No problem, that is part of the process. Check back in line 28 to 32 if you\u2019ll have to tweak something. Programming is all about making slight changes, testing, changing again till the script does what you want.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you\u2019ve made it this far in the article, congratulations! You\u2019re doing some highly technical work or at least working it out by yourself. Regardless of the results you\u2019re creating, that should be respected. If you\u2019re just not able to get it right, no worries. <a href=\"https:\/\/www.sheetgo.com\/contact-sales\/\" target=\"_blank\" rel=\"noopener\">Reach out to us<\/a>, let us know the result you\u2019re trying to create for your project and our expert consultant can help you out. <\/span><\/p>\n<p>[\/et_pb_text][et_pb_code _builder_version=&#8221;4.20.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_code][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is JSON? JSON stands for &#8220;JavaScript Object Notation&#8221;. It is a way to represent data in a simple, easy-to-read format that can be easily used by many programming languages. Imagine you have a big bag of toys and you want to organize them. You could use different bags to put each kind of toy [&hellip;]<\/p>\n","protected":false},"author":42,"featured_media":42182,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[37],"tags":[39,28],"class_list":["post-42359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-sheets-features","tag-connections-t","tag-spreadsheets"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts\/42359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/comments?post=42359"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/posts\/42359\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/media\/42182"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/media?parent=42359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/categories?post=42359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/es\/wp-json\/wp\/v2\/tags?post=42359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}