Пример #1
0
    public void Returns_Value()
    {
        // Arrange
        var value = Rnd.Str;
        var param = new Jsonb(value);

        // Act
        var result = param.ToString();

        // Assert
        Assert.Equal(value, result);
    }
Пример #2
0
        public static string GetStringValue(this Jsonb jsonb, string key)
        {
            // We can also do: if (jsonb.ToString() != null)
            // But it's better to abstract things out to future-proof things,
            // we might want to use blank instead of null in the future.

            if (jsonb != Jsonb.Null)
            {
                var d = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonb.ToString());
                if (d.ContainsKey(key))
                {
                    return((string)d[key]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }