LSEQTree icon indicating copy to clipboard operation
LSEQTree copied to clipboard

Optimize json output by adding toJSON()

Open sfescape opened this issue 7 years ago • 0 comments

You can reduce the size of the JSON output significantly just by dropping the subCounter field as well as empty children fields.

toJSON() { return JSON.stringify(this, function(key, value) { return key === 'subCounter' || (key === 'children' && value.length === 0) ? undefined : value }) }

You would need to add a check for children in fromJSON to either default children to [] or skip processing children if the field is undefined.

sfescape avatar Aug 06 '18 15:08 sfescape