// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.Internal;
using Microsoft.Framework.Internal;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
namespace Microsoft.AspNet.Mvc
{
public class JsonInputFormatter : InputFormatter
{
private JsonSerializerSettings _serializerSettings;
public JsonInputFormatter()
: this(SerializerSettingsProvider.CreateSerializerSettings())
{
}
public JsonInputFormatter([NotNull] JsonSerializerSettings serializerSettings)
{
_serializerSettings = serializerSettings;
SupportedEncodings.Add(UTF8EncodingWithoutBOM);
SupportedEncodings.Add(UTF16EncodingLittleEndian);
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/json"));
}
///
/// Gets or sets the used to configure the .
///
public JsonSerializerSettings SerializerSettings
{
get
{
return _serializerSettings;
}
[param: NotNull]
set
{
_serializerSettings = value;
}
}
///
public override Task