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

Question on using JSON as database in Handouts and Roll Tables?

So, not having a compendium for Castles & Crusades, I want to start adding in more content to make my games run more smoothly.  Some of this is in the shape of tables, wanting to have multi-columned data sets for the tables is one piece.  So for this I was wondering pros/cons dos/don'ts of using JSON in handouts and Roll Tables.  For example, I want to have a database of monsters to pull from, and could put the following in a handout GM's section -  {Monsters: { {monsterID: 0, Name: 'Aboleth', NoEncountered: '1-4', Size: 'Large', HD: '9 (d8)', NoHD: 9, HDType: 8, ExtraHP: 0, Move: '10 ft.; 60 ft. (swim)', AC: 16, Attacks: '4 Tentacle (1d6+8)', Special: 'Enslave, Spell-like abilities, Slime, Darkvision 60 ft., Mucus Cloud', Saves: 'M', Int: 'High', AL: 'Lawful Evil', Type: 'Aberration', Treasure: 8, XP: '1610+9', XPBase: 1610, XPPerHP: 9, StrengthPri: 0, Strength: 10, StrengthMod: 0, DexterityPri: 0, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 0, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 1, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 1, Wisdom: 10, WisdomMod: 0, CharismaPri: 1, Charisma: 10, CharismaMod: 0', Book: 'M&T' }, {monsterID: 1, Name: 'Achaierai (Individual) [M&T]', NoEncountered: '1', Size: 'Large', HD: '6 (d8)', NoHD: 6, HDType: 8, ExtraHP: 0, Move: '50 ft.', AC: 20, Attacks: '2 Claw (1d6+2), Bite (1d6+4)', Special: 'Darkvision 60 ft., SR 5, Limited Regeneration, Height', Saves: 'P', Int: 'High', AL: 'Chaotic Evil', Type: 'Extraplanar', Treasure: 6, XP: '540+6', XPBase: 540, XPPerHP: 6, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 2, Name: 'Achaierai (Group) [M&T]', NoEncountered: '2-5', Size: 'Large', HD: '6 (d8)', NoHD: 6, HDType: 8, ExtraHP: 0, Move: '50 ft.', AC: 20, Attacks: '2 Claw (1d6+2), Bite (1d6+4)', Special: 'Darkvision 60 ft., SR 5, Limited Regeneration, Height', Saves: 'P', Int: 'High', AL: 'Chaotic Evil', Type: 'Extraplanar', Treasure: 6, XP: '540+6', XPBase: 540, XPPerHP: 6, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0,, Book: 'M&T' }, {monsterID: 3, Name: 'Allip', NoEncountered: '1', Size: 'Medium', HD: '4 (d12)', NoHD: 4, HDType: 12, ExtraHP: 0, Move: '30 ft. (fly)', AC: 15, Attacks: 'Touch (ability drain)', Special: 'Wisdom Drain, Babble, Madness, Darkvision 60 ft., Incorporeal', Saves: 'M', Int: 'Average', AL: 'Neutral Evil', Type: 'Extraordinary Undead', Treasure: 5, XP: '170+4', XPBase: 170, XPPerHP: 4, StrengthPri: 0, Strength: 10, StrengthMod: 0, DexterityPri: 0, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 0, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 1, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 1, Wisdom: 10, WisdomMod: 0, CharismaPri: 1, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 4, Name: 'Ant, Giant (Worker, Gathering)', NoEncountered: '10-50', Size: 'Small', HD: '1 (d6)', NoHD: 1, HDType: 6, ExtraHP: 0, Move: '50 ft., 20 ft. (climb)', AC: 16, Attacks: 'Bite (1d3)', Special: 'None', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '5+1', XPBase: 5, XPPerHP: 1, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 5, Name: 'Ant, Giant (Worker, Nest)', NoEncountered: '100-900', Size: 'Small', HD: '1 (d6)', NoHD: 1, HDType: 6, ExtraHP: 0, Move: '50 ft., 20 ft. (climb)', AC: 16, Attacks: 'Bite (1d3)', Special: 'None', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '5+1', XPBase: 5, XPPerHP: 1, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 6, Name: 'Ant, Giant (Soldier, Patrol)', NoEncountered: '1-10', Size: 'Small', HD: '2 (d8)', NoHD: 2, HDType: 8, ExtraHP: 0, Move: '50 ft., 20 ft. (climb)', AC: 16, Attacks: 'Bite (1d4+1)', Special: 'Acid Sting', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '20+2', XPBase: 20, XPPerHP: 2, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 7, Name: 'Ant, Giant (Soldier, Nest)', NoEncountered: '10-100', Size: 'Small', HD: '2 (d8)', NoHD: 2, HDType: 8, ExtraHP: 0, Move: '50 ft., 20 ft. (climb)', AC: 16, Attacks: 'Bite (1d4+1)', Special: 'Acid Sting', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '20+2', XPBase: 20, XPPerHP: 2, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 8, Name: 'Ant, Giant (Queen)', NoEncountered: '1', Size: 'Small', HD: '5 (d8)', NoHD: 5, HDType: 8, ExtraHP: 0, Move: '50 ft., 20 ft. (climb)', AC: 16, Attacks: 'Bite (1d8)', Special: 'None', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '80+5', XPBase: 80, XPPerHP: 5, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 9, Name: 'Ankheg', NoEncountered: '1-6', Size: 'Large', HD: '5 (d10)', NoHD: 5, HDType: 10, ExtraHP: 0, Move: '30 ft., 20 ft. burrow', AC: 18, Attacks: 'Bite (3d6+1d4)', Special: 'Improved Grab, Spit Acid, Twilight Vision', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Beast', Treasure: 5, XP: '220+5', XPBase: 220, XPPerHP: 5, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' }, {monsterID: 10, Name: 'Ape , Great', NoEncountered: '1-20', Size: 'Medium', HD: '3 (d8)', NoHD: 3, HDType: 8, ExtraHP: 0, Move: '30 ft., 30 ft. (climb)', AC: 14, Attacks: '2 Claw (1d3), Bite (1d6)', Special: 'Rend, Twilight Vision', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '30+3', XPBase: 30, XPPerHP: 3, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' } }} Of course it will be much larger, I have some 760 total monsters I would want to load up this way.  I would write API scripts to parse this and load it into a character sheet when I wanted the monster created.  Note that I have some scrubbing to do of my data files, but have been using this format already in an API to build monsters as I need them for the adventures I am setting up.  Basically instead of a large JSON dataset I have an array of individual JSON strings that I pull the data out of and load into the character sheet. But I want to be able to dynamically pull the monsters during the game.  I could have that all be in the API with the database of all the monsters in there, but I don't want to bloat those files and consume all that RAM.  I could continue with the way I am doing it now, and have separate game with all of the monsters in it, but then I would have to use the transmogrifier during the game, then pull the monsters into the map, doable but slower.  So if this data is stored in a handout, that is only available to me as the GM, what is the impact to the Roll20 system if I pull that data into the API from the handout into an object and then query the object for the data I am looking for to create the monster?  Note that I may have the full monster description in my final import, but not sure on that as yet, if I do that will make the data size grow quite a bit. I also am going to be looking at making actual usable information from the Attacks, and possibly later from the special abilities.  For this it would be easy enough to split them up to nested JSON values such as this -  {monsterID: 10, Name: 'Ape , Great', NoEncountered: '1-20', Size: 'Medium', HD: '3 (d8)', NoHD: 3, HDType: 8, ExtraHP: 0, Move: '30 ft., 30 ft. (climb)', AC: 14, Attacks: '2 Claw (1d3), Bite (1d6)', AttackType: [{Description: 'Claw', ToHitMod: 0, BaseDamage: '1d3', DamageMod: '0'},{Description: 'Bite', ToHitMod: 0, BaseDamage: '1d6', DamageMod: '0'}] , Special: 'Rend, Twilight Vision', Saves: 'P', Int: 'Animal', AL: 'Neutral', Type: 'Animal', Treasure: 0, XP: '30+3', XPBase: 30, XPPerHP: 3, StrengthPri: 1, Strength: 10, StrengthMod: 0, DexterityPri: 1, Dexterity: 10, DexterityMod: 0, ConstitutionPri: 1, Constitution: 10, ConstitutionMod: 0, IntelligencePri: 0, Intelligence: 10, IntelligenceMod: 0, WisdomPri: 0, Wisdom: 10, WisdomMod: 0, CharismaPri: 0, Charisma: 10, CharismaMod: 0, Book: 'M&T' } The special abilities would follow the same format.  I probably would combine this with some Roll Tables, for things like Wandering Monsters, and those tables would have JSON for the Monster ID number, and number appearing. For other tables, I would look at using a combination of Roll Tables with JSON for the table result.  The result could be something as simple as just multiple values, or as complex as delving into multiple additional table rolls, such as rolling through treasure generation for a monster based on its treasure type. So, just wondering if this is doable, and if so, is there anything that should be avoided?
1522616106
The Aaron
Pro
API Scripter
While it is doable, I would recommend just putting that in a plain JavaScript object in the API. It will be more efficient both in ram and in speed of access. JSON is great as an interchange format, but you pay a heavy overhead in encoding and decoding that you don’t need to do as you’re only ever accessing it via the API, and never interchanging it. You might as well store it in the most efficient and accessible format for the intended use. 
Thanks, I will end up doing that then.  As always a wealth of information!
1522622984
The Aaron
Pro
API Scripter
No problem!