toBody method

String toBody({
  1. bool bigIntAsString = false,
})

Implementation

String toBody({bool bigIntAsString = false}) {
  final Map<String, BigInt> replace = {};
  int id = 0;
  String bodyString = StringUtils.fromJson(
    jsonBody,
    toEncodable: (object) {
      if (object is! BigInt) return object.toString();
      if (object.isValidInt) {
        return object.toInt();
      }
      if (bigIntAsString) return object.toString();
      final n = '${id++}#${object.toString()}';
      replace[n] = object;

      return n;
    },
  );
  for (final i in replace.entries) {
    bodyString = bodyString.replaceFirst('"${i.key}"', '${i.value}');
  }
  return bodyString;
}