示例#1
0
        public static void MinifyJson(ReadOnlySpan <byte> input, Span <byte> output, out int bytesWritten)
        {
            if ((uint)input.Length < 1)
            {
                bytesWritten = 0;
                return;
            }

            if ((uint)output.Length < 1)
            {
                throw new ArgumentException("Output is empty");

                //TODO: how to validate output length?

                fixed(byte *inputPtr = input)
                fixed(byte *outputPtr = output)
                {
                    bytesWritten = (int)JsonMinifier.Minify(inputPtr, (ulong)input.Length, outputPtr);
                }
        }
示例#2
0
        public static void MinifyJson(ReadOnlySpan <byte> input, Span <byte> output, out int bytesWritten)
        {
#if JSON_MINIFY
            if ((uint)input.Length < 1)
            {
                bytesWritten = 0;
                return;
            }

            if ((uint)output.Length < 1)
            {
                throw new ArgumentException("Output is empty");

                //TODO: how to validate output length?

                fixed(byte *inputPtr = input)
                fixed(byte *outputPtr = output)
                {
                    bytesWritten = (int)JsonMinifier.Minify(inputPtr, (ulong)input.Length, outputPtr);
                }
#else
            throw new NotSupportedException("SimdJsonSharp was compiled without `JSON_MINIFY`.");
#endif
        }