コード例 #1
0
        public void Table_FromJSON_ShemaOnly()
        {
            var src = new Table(new TeztRow().Schema);
            var options = new NFX.Serialization.JSON.JSONWritingOptions
                                  {
                                    RowsetMetadata = true,
                                    SpaceSymbols = true,
                                    IndentWidth = 2,
                                    MemberLineBreak = true,
                                    ObjectLineBreak = true
                                  };
            var json = src.ToJSON(options);

            var trg = RowsetBase.FromJSON(json, true);

            schemaAssertions(trg.Schema, src.Schema);
            Assert.AreEqual(trg.Count, 0);
        }
コード例 #2
0
        public void Table_FromJSON(bool rowsAsMap)
        {
            var row = new TeztRow();
            var src = new Table(row.Schema);

            row.BoolField = true;
            row.CharField = 'a';
            row.StringField = "aaa";
            row.DateTimeField = new DateTime(2016, 1, 2);
            row.GDIDField = new GDID(1, 2, 3);

            row.ByteField = 100;
            row.ShortField = -100;
            row.IntField = -999;

            row.UIntField = 254869;
            row.LongField = -267392;

            row.FloatField = 32768.32768F;
            row.DoubleField = -1048576.1048576D;

            row.DecimalField = 1.0529M;

            row.NullableField = null;

            row.ArrayInt = new int[] {-1, 0, 1};
            row.ListString = new List<string> {"one", "two", "three"};
            row.DictionaryIntStr = new Dictionary<int, string>
            {
              {1, "first"},
              {2, "second"}
            };

            row.RowField = new Person { Name = "John", Age = 20 };

            src.Add(row);

            row.BoolField = false;
            row.CharField = 'b';
            row.StringField = "bbb";
            row.DateTimeField = new DateTime(2016, 2, 1);
            row.GDIDField = new GDID(4, 5, 6);

            row.ByteField = 101;
            row.ShortField = 100;
            row.IntField = 999;

            row.UIntField = 109876;
            row.LongField = 267392;

            row.FloatField = -32768.32768F;
            row.DoubleField = -048576.1048576D;

            row.DecimalField = -1.0529M;

            row.NullableField = null;

            row.ArrayInt = new int[] {1, 0, -1};
            row.ListString = new List<string> { "three","two", "one" };
            row.DictionaryIntStr = new Dictionary<int, string>
            {
              {0, "zero"},
              {1, "first"},
              {2, "second"}
            };

            row.RowField = new Person { Name = "Ann", Age = 19 };

            src.Add(row);

            var options = new NFX.Serialization.JSON.JSONWritingOptions
                                  {
                                    RowsetMetadata = true,
                                    SpaceSymbols = true,
                                    IndentWidth = 2,
                                    MemberLineBreak = true,
                                    ObjectLineBreak = true,
                                    RowsAsMap = rowsAsMap
                                  };
            var json = src.ToJSON(options);

            var trg = RowsetBase.FromJSON(json);

            schemaAssertions(trg.Schema, src.Schema);
            rowsAssertions(src, trg, rowsAsMap);
        }