Beispiel #1
0
    public void EscapeValues()
    {
        var data = new Dictionary <string, object>
        {
            { "foo", "\x00 \x1f \t \r \n \\ \"Hello!\"" }
        };

        var result = JsonExtentions.ToJson(data);

        Assert.Equal(@"{""foo"":""\u0000 \u001F \t \r \n \\ \""Hello!\""""}", result);
    }
Beispiel #2
0
    public void SimpleValues()
    {
        var data = new Dictionary <string, object>
        {
            { "string", "bar" },
            { "int32", 42 },
            { "int64", 42L },
            { "single", 21.12F },
            { "double", 21.12 },
            { "decimal", 21.12M },
            { "boolean", true },
            { "guid", Guid.Empty },
        };

        var result = JsonExtentions.ToJson(data);

        Assert.Equal(@"{""string"":""bar"",""int32"":42,""int64"":42,""single"":21.12,""double"":21.12,""decimal"":21.12,""boolean"":true,""guid"":""00000000-0000-0000-0000-000000000000""}", result);
    }
Beispiel #3
0
 public string ToJson(string JsonString)
 {
     return(JsonExtentions.SerializeToJson(this));
 }
Beispiel #4
0
 public static Myobject  GetObject(string JsonString)
 {
     return(JsonExtentions.JsonToObject <Myobject>(JsonString));
 }