HOLIDAY GIFT for constructers

0 favourites
  • 1 posts
From the Asset Store
Join Santa in a festive battle against sneaky thieves in "Santa's Gift Box".
  • I did a code that converts google sheets into construct 3 JSON string

    You just need to copy/paste this code inside the new apps script, press RUN button and json string will be ready

    function convertToJSON() {
     var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
     var sheet = spreadsheet.getActiveSheet();
    
     var data = sheet.getDataRange().getValues();
     var jsonData = {
     "\"c2array\"": true,
     "\"size\"": [data.length, data[0].length, 1],
     "\"data\"": [] 
     };
    
     for (var i = 0; i < data.length; i++) {
     var row = [];
     for (var j = 0; j < data[i].length; j++) {
     if (typeof data[i][j] === 'string') {
     row.push(['"' + String(data[i][j]).replace(/"/g, '""') + '"']); 
     } else {
     row.push([data[i][j]]); 
     }
     }
     jsonData["\"data\""].push(row); 
     }
    
     var jsonString = JSON.stringify(jsonData);
     jsonString = jsonString.replace(/\\/g, ''); 
     console.log('"'+jsonString+'"'); 
    
    }

    Enjoy

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)