exportToJson method

String exportToJson(
  1. String? indentation,
  2. bool debug
)

Exports a representation of the log, in JSON format.

param indentation The indentation of the json string. param debug Indicates whether debug information is added to the log. return The result. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

String exportToJson(String? indentation, bool debug) {
  Pointer<Char>? pIndentation = indentation?.toNativeUtf8().cast<Char>();
  Pointer<Char> pResult = nullptr;
  Pointer<Int> pResultSize = calloc.allocate(1);
  pResultSize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealLog_ExportToJson(_pHandle.value, pIndentation ?? nullptr, debug, pResult, pResultSize);
    if (err == BiosealError.insufficientBuffer.value) {
      pResult = calloc.allocate(pResultSize.value);
      err = biosealSDK.id3BiosealLog_ExportToJson(_pHandle.value, pIndentation ?? nullptr, debug, pResult, pResultSize);
      if (err != BiosealError.success.value) {
        throw BiosealException(err);
      }
    }
    final vResult = utf8.decode(Uint8List.fromList(pResult.cast<Uint8>().asTypedList(pResultSize.value)));
    return vResult;
  } finally {
    if (pIndentation != null) {
      calloc.free(pIndentation);
    }
    calloc.free(pResult);
    calloc.free(pResultSize);
  }
}