Ejemplo n.º 1
0
            public static LdValue ReadJsonValue(ref JReader reader)
            {
                var value = reader.Any();

                switch (value.Type)
                {
                case JsonStream.ValueType.Bool:
                    return(LdValue.Of(value.BoolValue));

                case JsonStream.ValueType.Number:
                    return(LdValue.Of(value.NumberValue));

                case JsonStream.ValueType.String:
                    return(LdValue.Of(value.StringValue.ToString()));

                case JsonStream.ValueType.Array:
                    var arrayBuilder = LdValue.BuildArray();
                    for (var arr = value.ArrayValue; arr.Next(ref reader);)
                    {
                        arrayBuilder.Add(ReadJsonValue(ref reader));
                    }
                    return(arrayBuilder.Build());

                case JsonStream.ValueType.Object:
                    var objBuilder = LdValue.BuildObject();
                    for (var obj = value.ObjectValue; obj.Next(ref reader);)
                    {
                        objBuilder.Add(obj.Name.ToString(), ReadJsonValue(ref reader));
                    }
                    return(objBuilder.Build());

                default:
                    return(LdValue.Null);
                }
            }