How to save a 2D array to a Script Property in Properties Service in Google App Script?










0















I have a 2D array that I need to save as a property in Google App Script. How would I do this?



var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']]

PropertiesService.getScriptProperties().setProperty('myArray', array)


When I run the code as listed above I get [Ljava.lang.Object;@40ac055f as the value.



When I us array.toString() the property value negates the square brackets.



Thanks in advance!










share|improve this question
























  • It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

    – Cooper
    Nov 12 '18 at 16:51
















0















I have a 2D array that I need to save as a property in Google App Script. How would I do this?



var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']]

PropertiesService.getScriptProperties().setProperty('myArray', array)


When I run the code as listed above I get [Ljava.lang.Object;@40ac055f as the value.



When I us array.toString() the property value negates the square brackets.



Thanks in advance!










share|improve this question
























  • It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

    – Cooper
    Nov 12 '18 at 16:51














0












0








0








I have a 2D array that I need to save as a property in Google App Script. How would I do this?



var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']]

PropertiesService.getScriptProperties().setProperty('myArray', array)


When I run the code as listed above I get [Ljava.lang.Object;@40ac055f as the value.



When I us array.toString() the property value negates the square brackets.



Thanks in advance!










share|improve this question
















I have a 2D array that I need to save as a property in Google App Script. How would I do this?



var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']]

PropertiesService.getScriptProperties().setProperty('myArray', array)


When I run the code as listed above I get [Ljava.lang.Object;@40ac055f as the value.



When I us array.toString() the property value negates the square brackets.



Thanks in advance!







arrays json google-apps-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 14:03









Sandy Good

20.3k115296




20.3k115296










asked Nov 12 '18 at 10:42









Brandon Pillay Brandon Pillay

7318




7318












  • It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

    – Cooper
    Nov 12 '18 at 16:51


















  • It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

    – Cooper
    Nov 12 '18 at 16:51

















It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

– Cooper
Nov 12 '18 at 16:51






It would be easier to save it in a sheet. It would also be easier read it out of a sheet.

– Cooper
Nov 12 '18 at 16:51













1 Answer
1






active

oldest

votes


















1














  • Note that Properties Store is meant to save specific properties and key values. It's not meant to be a replacement for the entire spreadsheet.


  • Current quotas1 limit the property value size per key to 9kB and total storage per store to 500kB.



  • If your requirement doesn't cross the limit described above, the easy way is to use JSON.stringify2, Which will convert it to a parsable string.



    var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']];
    var jarray = JSON.stringify(array);
    PropertiesService.getScriptProperties().setProperty('myArray', jarray);



  • You can then use JSON.parse3 to retrieve the array



    var array = JSON.parse(jarray);






share|improve this answer























  • Works perfectly. Thank you!

    – Brandon Pillay
    Nov 14 '18 at 8:39










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260460%2fhow-to-save-a-2d-array-to-a-script-property-in-properties-service-in-google-app%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














  • Note that Properties Store is meant to save specific properties and key values. It's not meant to be a replacement for the entire spreadsheet.


  • Current quotas1 limit the property value size per key to 9kB and total storage per store to 500kB.



  • If your requirement doesn't cross the limit described above, the easy way is to use JSON.stringify2, Which will convert it to a parsable string.



    var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']];
    var jarray = JSON.stringify(array);
    PropertiesService.getScriptProperties().setProperty('myArray', jarray);



  • You can then use JSON.parse3 to retrieve the array



    var array = JSON.parse(jarray);






share|improve this answer























  • Works perfectly. Thank you!

    – Brandon Pillay
    Nov 14 '18 at 8:39















1














  • Note that Properties Store is meant to save specific properties and key values. It's not meant to be a replacement for the entire spreadsheet.


  • Current quotas1 limit the property value size per key to 9kB and total storage per store to 500kB.



  • If your requirement doesn't cross the limit described above, the easy way is to use JSON.stringify2, Which will convert it to a parsable string.



    var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']];
    var jarray = JSON.stringify(array);
    PropertiesService.getScriptProperties().setProperty('myArray', jarray);



  • You can then use JSON.parse3 to retrieve the array



    var array = JSON.parse(jarray);






share|improve this answer























  • Works perfectly. Thank you!

    – Brandon Pillay
    Nov 14 '18 at 8:39













1












1








1







  • Note that Properties Store is meant to save specific properties and key values. It's not meant to be a replacement for the entire spreadsheet.


  • Current quotas1 limit the property value size per key to 9kB and total storage per store to 500kB.



  • If your requirement doesn't cross the limit described above, the easy way is to use JSON.stringify2, Which will convert it to a parsable string.



    var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']];
    var jarray = JSON.stringify(array);
    PropertiesService.getScriptProperties().setProperty('myArray', jarray);



  • You can then use JSON.parse3 to retrieve the array



    var array = JSON.parse(jarray);






share|improve this answer













  • Note that Properties Store is meant to save specific properties and key values. It's not meant to be a replacement for the entire spreadsheet.


  • Current quotas1 limit the property value size per key to 9kB and total storage per store to 500kB.



  • If your requirement doesn't cross the limit described above, the easy way is to use JSON.stringify2, Which will convert it to a parsable string.



    var array = [['value 1', 1.0, 'A'],['value 2', 2.0, 'B'],['value 3', 3.0, 'C']];
    var jarray = JSON.stringify(array);
    PropertiesService.getScriptProperties().setProperty('myArray', jarray);



  • You can then use JSON.parse3 to retrieve the array



    var array = JSON.parse(jarray);







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 13:03









TheMasterTheMaster

9,6093731




9,6093731












  • Works perfectly. Thank you!

    – Brandon Pillay
    Nov 14 '18 at 8:39

















  • Works perfectly. Thank you!

    – Brandon Pillay
    Nov 14 '18 at 8:39
















Works perfectly. Thank you!

– Brandon Pillay
Nov 14 '18 at 8:39





Works perfectly. Thank you!

– Brandon Pillay
Nov 14 '18 at 8:39

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260460%2fhow-to-save-a-2d-array-to-a-script-property-in-properties-service-in-google-app%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo