How to save a 2D array to a Script Property in Properties Service in Google App Script?
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
add a comment |
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
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
add a comment |
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
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
arrays json google-apps-script
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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);
Works perfectly. Thank you!
– Brandon Pillay
Nov 14 '18 at 8:39
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
Works perfectly. Thank you!
– Brandon Pillay
Nov 14 '18 at 8:39
add a comment |
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);
Works perfectly. Thank you!
– Brandon Pillay
Nov 14 '18 at 8:39
add a comment |
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);
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);
answered Nov 12 '18 at 13:03
TheMasterTheMaster
9,6093731
9,6093731
Works perfectly. Thank you!
– Brandon Pillay
Nov 14 '18 at 8:39
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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