public void WriteEmbeddedObjectUsingSimplifiedSyntax()
        {
            using (writer.WriteArray())
            {
                using (writer.WriteObject())
                {
                    writer.WriteMember("Name", "Paweł");
                    writer.WriteMember("Salary", 100);
                    using (writer.WriteObject("Company"))
                    {
                        writer.WriteMember("Name", "CodeTitans");
                        writer.WriteMember("Address", "ABCD");
                        writer.WriteMember("Value", 10.28437411e2);
                        writer.WriteMember("Started", DateTime.Now);
                        writer.WriteMemberNull("Account");
                    }
                }

                using (writer.WriteObject())
                {
                    writer.WriteMember("Name", "Aga");
                    writer.WriteMember("Salary", 200);
                }

                writer.WriteValue(101);
                writer.WriteValue("New Item");
            }
        }
        public void ParseSerializedCurrentDateAsJavaScript()
        {
            var writer = new JSonWriter();
            var now    = DateTime.Now;

            // remove miliseconds:
            now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Kind);

            using (writer.WriteObject())
                writer.WriteMember("date", now, JSonWriterDateFormat.JavaScript);

            var reader = new JSonReader(writer.ToString());
            var item   = reader.ReadAsJSonObject();
            var date   = item["date"].DateTimeValue;

            Assert.AreEqual(now, date);
        }
        public void ParseSerializedCurrentDateAsEpochSeconds()
        {
            var writer = new JSonWriter();
            var now    = DateTime.Now;

            using (writer.WriteObject())
                writer.WriteMember("date", now, JSonWriterDateFormat.UnixEpochSeconds);

            // remove below seconds:
            now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Kind);

            var reader = new JSonReader(writer.ToString());
            var item   = reader.ReadAsJSonObject();
            var date   = item["date"].ToDateTimeValue(JSonDateTimeKind.UnixEpochSeconds);

            Assert.AreNotEqual(0, item["date"].Int64Value);
            Assert.AreEqual(now, date);
        }