Пример #1
0
        public void EmptyArray()
        {
            JsonObject jsonObject = JsonParser.Parse(@"{ ""array"" : [] }")["array"];

            Assert.IsTrue(jsonObject.IsArray);
            Assert.AreEqual(0, jsonObject.AsArray <long>().Length);
        }
Пример #2
0
        public void EmptyArray()
        {
            var json = @"{ ""intArray"" : [] }";

            JsonObject jsonObject = JsonParser.Parse(json)["intArray"];

            Assert.IsTrue(jsonObject.IsArray);
            Assert.AreEqual(0, jsonObject.AsArray <long>().Length);
        }
Пример #3
0
        protected override IEnumerable <object> ReadRecords()
        {
            if (!FileIO.Delegates.FileExists(_fileName))
            {
                return(new Object[0]);
            }

            JsonObject json = JsonParser.Parse(FileIO.Delegates.ReadAllText(_fileName));

            return(json.AsArray());
        }
Пример #4
0
        private void WriteJsonObject(JsonObject jsonObject)
        {
            if (jsonObject == null)
                return;

            if (jsonObject.IsArray)
                WriteArray(jsonObject.AsArray());
            else if (jsonObject.IsValue)
                WriteValue(jsonObject.Value);
            else if (jsonObject.IsObject)
            {
                bool sep = false;

                _output.Append('{');

                foreach (var field in jsonObject.Keys)
                {
                    if (sep)
                        _output.Append(',');

                    WritePair(field, jsonObject[field]);

                    sep = true;
                }

                _output.Append('}');
            }
        }