toJson method
Converts this and returns a Map representing a JSON object.
This allows for easy integration with dart's JsonEncoder class.
Implementation
@override
Map toJson() {
return {
...super.toJson(),
'begin': begin,
'end': end,
if (beginCaptures.isNotEmpty)
'beginCaptures': beginCaptures.stringifyKeys(),
if (endCaptures.isNotEmpty)
'endCaptures': endCaptures.stringifyKeys(),
};
}