Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

help with export character data

1516331684

Edited 1516360397
Sad
Sheet Author
API Scripter
iam try to make import export function.    // JSON Import on("change:import_json", function() {     getAttrs(["import_json"], function(values)  {         var jsonData = JSON.parse(values.import_json);         var characterData = jsonData[0];         // Import Info name player occupation sex age birthplace residence         setAttrs({character_name: characterData["character_name"]}); it work well. but export is not working. on('sheet:opened',function(){       getAttrs(["str"], function(values) {           var jsonDataExport = JSON.parse(values.str);         var characterData = jsonDataExport[0];             setAttrs({export_json:characterData});             });         }); Need advice/suggestions ! Thanks!
For exports you can probably just use the&nbsp; Character Vault .&nbsp; If you really need to export values as JSON you will first need to built a javascript Object. The following may help you get started: <a href="https://www.w3schools.com/js/js_json.asp" rel="nofollow">https://www.w3schools.com/js/js_json.asp</a> <a href="https://www.w3schools.com/js/js_json_intro.asp" rel="nofollow">https://www.w3schools.com/js/js_json_intro.asp</a> In short for export I think you would want to use JSON.stringify() instead of JSON.parse().&nbsp; In addition you wouldn't want to use [0] on jsonDataExport unless jsonDataExport is an array of values and you only want the first one. The original Import code is expecting data in a form like this:&nbsp;<a href="http://skoll.xyz/mythras_eg/generate_enemies_json/?id=1778&amount=1" rel="nofollow">http://skoll.xyz/mythras_eg/generate_enemies_json/?id=1778&amount=1</a>.&nbsp; The [0] simply ensures I'm only pulling the first character generated if the user generated more than one with $amount=2 or more.
1516379115
Sad
Sheet Author
API Scripter
Matt Carpenter said: For exports you can probably just use the&nbsp; Character Vault .&nbsp; If you really need to export values as JSON you will first need to built a javascript Object. The following may help you get started: <a href="https://www.w3schools.com/js/js_json.asp" rel="nofollow">https://www.w3schools.com/js/js_json.asp</a> <a href="https://www.w3schools.com/js/js_json_intro.asp" rel="nofollow">https://www.w3schools.com/js/js_json_intro.asp</a> In short for export I think you would want to use JSON.stringify() instead of JSON.parse().&nbsp; In addition you wouldn't want to use [0] on jsonDataExport unless jsonDataExport is an array of values and you only want the first one. The original Import code is expecting data in a form like this:&nbsp; <a href="http://skoll.xyz/mythras_eg/generate_enemies_json/?id=1778&amount=1" rel="nofollow">http://skoll.xyz/mythras_eg/generate_enemies_json/?id=1778&amount=1</a> .&nbsp; The [0] simply ensures I'm only pulling the first character generated if the user generated more than one with $amount=2 or more. thankyou so much.