derikb / rpg-table-randomizer

Module for random tables for use in roleplaying games.
GNU General Public License v3.0
9 stars 2 forks source link

Serializing NPCs with field values that are Results doesn't work. #50

Closed derikb closed 2 years ago

derikb commented 2 years ago

Calling toJSON outside the context of a JSON.stringify doesn't recursive call toJSON on all the properties, so trying to create serializable objects from the NPC class fails if there are results or result sets in the field values.

defaultToJSON probably needs to check for "toJSON" method on any objects and call it if it's there.