Deserialize() public method

public Deserialize ( JsonReader reader, Type objectType, bool checkAdditionalContent ) : object
reader JsonReader
objectType Type
checkAdditionalContent bool
return object
コード例 #1
0
 internal override object DeserializeInternal(JsonReader reader, Type objectType)
 {
     if (_serializerReader != null)
     {
         return(_serializerReader.Deserialize(reader, objectType));
     }
     else
     {
         return(_serializer.Deserialize(reader, objectType));
     }
 }
コード例 #2
0
        internal virtual object DeserializeInternal(JsonReader reader, Type objectType)
        {
            ValidationUtils.ArgumentNotNull(reader, "reader");

              JsonSerializerInternalReader serializerReader = new JsonSerializerInternalReader(this);
              return serializerReader.Deserialize(reader, objectType);
        }
コード例 #3
0
	private object ReadObject(JsonReader reader, JsonSerializer serializer)
    {
      IDictionary<string, object> expandoObject = new ExpandoObject();

      while (reader.Read())
      {
        switch (reader.TokenType)
        {
          case JsonToken.PropertyName:
			string propertyName = reader.Value.ToString();
			if (!reader.Read())
			  throw new Exception("Unexpected end.");

			object v = ReadValue(reader, serializer);

			if (propertyName == "$type")
			{
			  //Assume that this is always the first property

			  Type objectType = null;
			  objectType = ((string)v).StartsWith("System.Dynamic.ExpandoObject,")
				  ? typeof(ExpandoObject)
				  : Type.GetType((string)v, true);

			  if (objectType != typeof(ExpandoObject))
			  {
				if (!reader.Read())
					throw new Exception("Unexpected end.");

			  	var jsonSerializerInternalReader = new JsonSerializerInternalReader(serializer);
			  	var expandoTypedObject = jsonSerializerInternalReader.Deserialize(reader, objectType);

			  	return expandoTypedObject;
			  }
			}
			else
			{
				expandoObject[propertyName] = v;
			}

        	break;
          case JsonToken.Comment:
            break;
          case JsonToken.EndObject:
            return expandoObject;
        }
      }

      throw JsonSerializationException.Create(reader, "Unexpected end when reading ExpandoObject.");
    }