Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Examples/JsonApiDotNetCoreExample/Models/TodoItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using JsonApiDotNetCore.Models;

Expand Down Expand Up @@ -26,12 +26,12 @@ public TodoItem()
[Attr("achieved-date", isFilterable: false, isSortable: false)]
public DateTime? AchievedDate { get; set; }


[Attr("updated-date")]
public DateTime? UpdatedDate { get; set; }



[Attr("offset-date")]
public DateTimeOffset? OffsetDate { get; set; }

public int? OwnerId { get; set; }
public int? AssigneeId { get; set; }
public Guid? CollectionId { get; set; }
Expand Down
9 changes: 7 additions & 2 deletions src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using JsonApiDotNetCore.Extensions;
Expand Down Expand Up @@ -36,8 +37,12 @@ public object Deserialize(string requestBody)
{
try
{
var bodyJToken = JToken.Parse(requestBody);

JToken bodyJToken;
using (JsonReader jsonReader = new JsonTextReader(new StringReader(requestBody)))
{
jsonReader.DateParseHandling = DateParseHandling.None;
bodyJToken = JToken.Load(jsonReader);
}
if (RequestIsOperation(bodyJToken))
{
_jsonApiContext.IsBulkOperationRequest = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public async Task Can_Post_TodoItem()
_context.SaveChanges();

var todoItem = _todoItemFaker.Generate();
var nowOffset = new DateTimeOffset();
var content = new
{
data = new
Expand All @@ -461,7 +462,8 @@ public async Task Can_Post_TodoItem()
{
{ "description", todoItem.Description },
{ "ordinal", todoItem.Ordinal },
{ "created-date", todoItem.CreatedDate }
{ "created-date", todoItem.CreatedDate },
{ "offset-date", nowOffset }
},
relationships = new
{
Expand Down Expand Up @@ -494,6 +496,7 @@ public async Task Can_Post_TodoItem()
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
Assert.Equal(todoItem.Description, deserializedBody.Description);
Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
Assert.Equal(nowOffset.ToString("yyyy-MM-ddTHH:mm:ssK"), deserializedBody.OffsetDate?.ToString("yyyy-MM-ddTHH:mm:ssK"));
Assert.Null(deserializedBody.AchievedDate);
}

Expand Down