예제 #1
0
        private static void Value(this IJsonWriter writer, IJsonValue?value)
        {
            if (value == null)
            {
                writer.Value(null);
            }
            else if (value.Type == Json.Type.Object)
            {
                writer.Object((JsonObject)value);
            }
            else if (value.Type == Json.Type.Array)
            {
                writer.ArrayStart();

                JsonValueCollection ArrayValue = (JsonValueCollection)value;
                foreach (IJsonValue ChildValue in ArrayValue)
                {
                    writer.Value(ChildValue);
                }

                writer.ArrayEnd();
            }
            else if (value.Type == Json.Type.String)
            {
                writer.Value(((JsonString)value).String);
            }
            else if (value.Type == Json.Type.Integer)
            {
                writer.Value(((JsonInteger)value).Number);
            }
            else if (value.Type == Json.Type.Float)
            {
                writer.Value(((JsonFloat)value).Number);
            }
            else if (value.Type == Json.Type.Boolean)
            {
                writer.Value(((JsonBool)value).Value);
            }
        }
예제 #2
0
 private static void Value(this IJsonWriter writer, IJsonValue value)
 {
     if (value == null)
     {
         writer.Value(null);
     }
     else if (value.Type == Json.Type.Object)
     {
         writer.Object((JsonObject)value);
     }
     else if (value.Type == Json.Type.Array)
     {
         writer.ArrayStart();
         var array = (JsonArray)value;
         foreach (var child in array)
         {
             writer.Value(child);
         }
         writer.ArrayEnd();
     }
     else if (value.Type == Json.Type.String)
     {
         writer.Value(((JsonString)value).String);
     }
     else if (value.Type == Json.Type.Integer)
     {
         writer.Value(((JsonInteger)value).Number);
     }
     else if (value.Type == Json.Type.Float)
     {
         writer.Value(((JsonFloat)value).Number);
     }
     else if (value.Type == Json.Type.Boolean)
     {
         writer.Value(((JsonBool)value).Value);
     }
 }