Beispiel #1
0
        public static ParsedJson ParseJson(byte *jsonData, int length, bool reallocIfNeeded = true)
        {
            var  pj = new ParsedJson();
            bool ok = pj.AllocateCapacity((ulong)length);

            if (ok)
            {
                JsonParse(jsonData, (ulong)length, pj, reallocIfNeeded);
            }
            else
            {
                throw new InvalidOperationException("failure during memory allocation");
            }
            return(pj);
        }
Beispiel #2
0
        public static ParsedJson ParseJson(byte *jsonData, ulong length, bool reallocIfNeeded = true)
        {
            var  pj = new ParsedJson();
            bool ok = pj.AllocateCapacity(length);

            if (ok)
            {
                JsonParse(jsonData, length, pj, reallocIfNeeded);
            }
            else
            {
                pj.isvalid   = false;
                pj.ErrorCode = JsonParseError.CAPACITY;
            }
            return(pj);
        }