This repository was archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
JsonInputFormatter doesn't log errors #3557
Comments
This is the code I tried to get the error: using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NodaTime;
using NodaTime.Serialization.JsonNet;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NodaTimeJson
{
class Program
{
static void Main(string[] args)
{
var json = GetContent();
var serializerSettings = new JsonSerializerSettings();
serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
serializerSettings.Converters.Add(NodaConverters.InstantConverter);
var trip = JsonConvert.DeserializeObject<TripCreationModel>(json, serializerSettings);
}
private static string GetContent()
{
using (var stream = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file.json")))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
public class TripCreationModel
{
public string Name { get; set; }
public Instant StartedAt { get; set; }
public Instant EndedAt { get; set; }
}
}
} You need to install {
"name": "Foo",
"startedAt": "2015-11-14T12:27:17.389Z",
"endedAt": "2015-11-14T12:27:45.206Z"
}
|
@tugberkugurlu we added a ton of logging code to MVC in RC1. Could you try the latest builds and see if you get back something more reasonable? |
I can confirm that we didn't do anything like what what @tugberkugurlu is asking for in RC1 😦 |
A flipped my Ryan coin and it landed on @ryanbrandenburg . |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am on MVC 6.0.0-beta8 and I had a JSON deserialization failure. It didn't log any errors but instead it just didn't bind anything and populated the model state. This is the response I had:
When I tried the same deserialization in isolation, I got the below error from
JsonConvert.DeserializeObject<T>
:I would expect to see this as a Debug level log so that I wouldn't need to dig deep to see what is going wrong. Would be also useful to log more info along with the error like what is the value, etc.
The text was updated successfully, but these errors were encountered: