toJson method

  1. @override
Map<String, dynamic> toJson({
  1. bool includeValues = true,
  2. dynamic valueToEncodable(
    1. V value
    )?,
})
inherited

Return Json representation of TTMultiMap.

Node tree stored as preorder traversal.

If includeValues is true then values are included and must be Json serialisable in their own right.

Implementation

@override
Map<String, dynamic> toJson(
    {bool includeValues = true,
    dynamic Function(V value)? valueToEncodable}) {
  ArgumentError.checkNotNull(includeValues, 'includeValues');

  // Default value transform
  valueToEncodable ??= (V e) => e;

  final map = <String, dynamic>{};
  final nodes = <List<dynamic>>[];
  _toJson(_root, nodes, includeValues, valueToEncodable);
  map[_JSONKEY_NODES] = nodes;
  map[_JSONKEY_KEYMAPPING] = keyMapping(null);
  return map;
}