encodeJson static method

BuBytes encodeJson(
  1. Object json, {
  2. String? indent,
  3. bool toStringEncodable = false,
  4. Object? toEncodable(
    1. dynamic
    )?,
  5. JsonEncodeOptions? options,
})

Encodes a JSON-serializable json object into a list of bytes.

Implementation

static BuBytes encodeJson(
  Object json, {
  String? indent,
  bool toStringEncodable = false,
  Object? Function(dynamic)? toEncodable,
  JsonEncodeOptions? options,
}) {
  if (toEncodable == null && toStringEncodable) {
    toEncodable = (e) => e.toString();
  }

  return JsonCodec.jsonEncodeBytes(
    json,
    indent: indent,
    options: options,
    toEncodable: toEncodable,
  );
}