title: Jil.DeserializationException: 'Expected digit'
body: <p>I am trying to implement the Jil serializer in WebAPI(C#). While deserializing throws the error like "Jil.DeserializationException: 'Expected digit'". I have attached the code samples.</p>
  
  <p>WebApiConfig.cs </p>
  
  <pre><code>        config.Formatters.Clear();
          var _jilOptions = new Options(dateFormat: DateTimeFormat.ISO8601, excludeNulls: true, includeInherited: true);
          config.Formatters.Add(new JilFormatter(_jilOptions));
  </code></pre>
  
  <p>JilFormatter.cs</p>
  
  <pre><code>public class JilFormatter : MediaTypeFormatter
      {
          private static readonly MediaTypeHeaderValue _applicationJsonMediaType = new MediaTypeHeaderValue("application/json");
          private static readonly MediaTypeHeaderValue _textJsonMediaType = new MediaTypeHeaderValue("text/json");
          private readonly Options _options;
  
          public JilFormatter(Options options)
          {
              _options = options;
              SupportedMediaTypes.Add(_applicationJsonMediaType);
              SupportedMediaTypes.Add(_textJsonMediaType);
  
              SupportedEncodings.Add(new UTF8Encoding(false, true));
              SupportedEncodings.Add(new UnicodeEncoding(false, true, true));
          }
  
          public override bool CanReadType(Type type)
          {
              if (type == null)
                  return false;
              return true;
          }
  
          public override bool CanWriteType(Type type)
          {
              if (type == null)
                  return false;
              return true;
          }
  
          public override Task&lt;object&gt; ReadFromStreamAsync(Type type, Stream input, HttpContent content, IFormatterLogger formatterLogger)
          {
              var reader = new StreamReader(input);
              var deserialize = TypedDeserializers.GetTyped(type);
              var result = deserialize(reader, _options);
              return Task.FromResult(result);
          }
  
          public override Task WriteToStreamAsync(Type type, object value, Stream output, HttpContent content, TransportContext transportContext)
          {
              var writer = new StreamWriter(output);
              JSON.Serialize(value, writer, _options);
              writer.Flush();
              return Task.FromResult(true);
          }
      }
  </code></pre>
  
  <p>TypedDeserializers class:</p>
  
  <pre><code>static class TypedDeserializers
      {
          private static readonly ConcurrentDictionary&lt;Type, Func&lt;TextReader, Options, object&gt;&gt; _methods;
          private static readonly MethodInfo _method = typeof(JSON).GetMethod("Deserialize", new[] { typeof(TextReader), typeof(Options) });
  
          static TypedDeserializers()
          {
              _methods = new ConcurrentDictionary&lt;Type, Func&lt;TextReader, Options, object&gt;&gt;();
          }
  
          public static Func&lt;TextReader, Options, object&gt; GetTyped(Type type)
          {
              return _methods.GetOrAdd(type, CreateDelegate);
          }
  
          private static Func&lt;TextReader, Options, object&gt; CreateDelegate(Type type)
          {
              return (Func&lt;TextReader, Options, object&gt;)_method
                  .MakeGenericMethod(type)
                  .CreateDelegate(typeof(Func&lt;TextReader, Options, object&gt;));
          }
      }
  </code></pre>
  
  <p>ReuestTest.cs</p>
  
  <pre><code>public class ReuestTest
      {        
          public long UserId { get; set; }
  
          public long MobileDeviceId { get; set; }
  
          public bool IsInitialLoad { get; set; }
  
      }
  </code></pre>
  
  <p>testController.cs</p>
  
  <pre><code>[HttpPost]
  public string GetAllDispatchestest(ReuestTest request)
  {
  return something;
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>{
      "Message": "An error has occurred.",
      "ExceptionMessage": "Expected digit",
      "ExceptionType": "Jil.DeserializationException",
      "StackTrace": "   at Jil.Deserialize.Methods._ReadInt64(TextReader reader)\r\n   at _DynamicMethod4(TextReader , Int32 )\r\n   at Jil.JSON.Deserialize[T](TextReader reader, Options options)\r\n   at api.myapi.com.Utilities.JilFormatter.ReadFromStreamAsync(Type type, Stream input, HttpContent content, IFormatterLogger formatterLogger) in F:\\Projects\\myapi\\myapi.Solution\\api.myapi.com\\Utilities\\JilFormatter.cs:line 51\r\n   at System.Net.Http.Formatting.MediaTypeFormatter.ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n   at System.Net.Http.HttpContentExtensions.&lt;ReadAsAsyncCore&gt;d__0`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.&lt;ExecuteBindingAsyncCore&gt;d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.HttpActionBinding.&lt;ExecuteBindingAsyncCore&gt;d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.&lt;ExecuteAsync&gt;d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.&lt;ExecuteAsync&gt;d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__1.MoveNext()"
  }
  </code></pre>