2

It seems that JSV deserializes an empty string as null. The following test fails for JSV but passes for JSON.

    class Foo
    {
        public string String { get; set; }
    }

    [TestFixture]
    public class TestJsvEmptyString
    {
        [Test]
        public void TestJsv()
        {
            Foo orig = new Foo() { String = string.Empty };

            string jsv = orig.ToJsv();
            Foo fromJsv = jsv.FromJsv<Foo>();

            Assert.AreEqual(orig.String, fromJsv.String);
        }

        [Test]
        public void TestJson()
        {
            Foo orig = new Foo() { String = string.Empty };

            string json = orig.ToJson();
            Foo fromJson = json.FromJson<Foo>();

            Assert.AreEqual(orig.String, fromJson.String);
        }
    }

Thanks for a great package!

Ron

1 Answers1

1

Empty strings are treated as null in the JSV Format, as it has no wire representation.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • The problem is that Servicestack OrmLite serializes objects as JSV, and when read from database we encounter this problem. – user3009388 Nov 19 '13 at 16:55
  • @user3009388 Just don't distinguish between empty string and nulls, otherwise you'd have to avoid using JSV and not blob complex types in OrmLite. – mythz Nov 19 '13 at 17:11