pyJsonDumps function
json.dumps(value, ensure_ascii=False): ", " and ": " separators, keys
in insertion order, non-ASCII kept. Dart's jsonEncode omits the spaces,
which would change the prompt and therefore the tokens.
Implementation
String pyJsonDumps(Object? value) => switch (value) {
null => 'null',
bool() => value ? 'true' : 'false',
num() => _pyNumber(value),
String() => _pyJsonString(value),
List() => '[${value.map(pyJsonDumps).join(', ')}]',
Map() =>
'{${[for (final MapEntry(:key, :value) in value.entries) '${_pyJsonString('$key')}: ${pyJsonDumps(value)}'].join(', ')}}',
_ => throw ArgumentError('cannot encode ${value.runtimeType} as JSON'),
};