public JsonBodyDeserializerFixture() { this.deserialize = new JsonBodyDeserializer(); this.testModel = new TestModel() { IntProperty = 12, StringProperty = "More cowbell", DateProperty = DateTime.Parse("2011/12/25"), ArrayProperty = new[] { "Ping", "Pong" } }; this.serializer = new JavaScriptSerializer(); this.serializer.RegisterConverters(JsonSettings.Converters); this.testModelJson = this.serializer.Serialize(this.testModel); }
public JsonBodyDeserializerFixture() { var environment = new DefaultNancyEnvironment(); environment.AddValue(JsonConfiguration.Default); this.deserialize = new JsonBodyDeserializer(environment); this.testModel = new TestModel() { IntProperty = 12, StringProperty = "More cowbell", DateProperty = DateTime.Parse("2011/12/25"), ArrayProperty = new[] { "Ping", "Pong" } }; this.serializer = new JavaScriptSerializer(); this.serializer.RegisterConverters(JsonConfiguration.Default.Converters); }
/// <summary> /// Gets the deserialized representation of the JSON in the response body using the default XML body deserializer. /// </summary> /// <typeparam name="TModel">The type that the JSON response body should be deserialized to.</typeparam> /// <param name="bodyWrapper">An instance of the <see cref="BrowserResponseBodyWrapper"/> that the extension should be invoked on.</param> /// <value>A <typeparamref name="TModel"/> instance representation of the HTTP response body.</value> public static TModel DeserializeJson<TModel>(this BrowserResponseBodyWrapper bodyWrapper) { var bodyDeserializer = new JsonBodyDeserializer(bodyWrapper.BrowserContext.Environment); return bodyWrapper.Deserialize<TModel>(bodyDeserializer); }
/// <summary> /// Gets the deserialized representation of the JSON in the response body using the default XML body deserializer. /// </summary> /// <typeparam name="TModel">The type that the JSON response body should be deserialized to.</typeparam> /// <param name="bodyWrapper">An instance of the <see cref="BrowserResponseBodyWrapper"/> that the extension should be invoked on.</param> /// <value>A <typeparamref name="TModel"/> instance representation of the HTTP response body.</value> public static TModel DeserializeJson <TModel>(this BrowserResponseBodyWrapper bodyWrapper) { var bodyDeserializer = new JsonBodyDeserializer(); return(bodyWrapper.Deserialize <TModel>(bodyDeserializer)); }