U4-8794 - Allow Newtosoft JSON 9.0.1 to be installed

Created by Daniel 30 Jul 2016, 12:30:59 Updated by Sebastiaan Janssen 23 Aug 2016, 08:49:06

Relates to: U4-8760

Hi,

I am trying to use Tag Helpers in a new created Umbraco project. I see that the 7.5.0 beta2, has still a restriction for Json < 9.0 while the https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.TagHelpers/1.0.0 (a dependant package) requires >= 9.0.1.

This is the error that I get from Visual Studio: Unable to find a version of 'Newtonsoft.Json' that is compatible with 'Microsoft.AspNetCore.JsonPatch 1.0.0 constraint: Newtonsoft.Json (>= 9.0.1)', 'Microsoft.AspNetCore.Mvc.ViewFeatures 1.0.0 constraint: Newtonsoft.Json (>= 9.0.1)', 'Microsoft.Extensions.DependencyModel 1.0.0 constraint: Newtonsoft.Json (>= 9.0.1)'.

Since this is the beta2, I guess that this restriction will remain in the new RTM version of Umbraco, and it would be great to use Tag Helpers.

Do you have any particular reason that you keep the JSON.NET constraint ?

Thanks

Comments

Sebastiaan Janssen 02 Aug 2016, 12:45:13

We've had some horrible upgrade problems with json.net in the past, which is why we don't dare update it again until v8. However, I'll update the limitations so you can manually install v9 as well.


Sebastiaan Janssen 02 Aug 2016, 12:46:07

Commit made by '''Sebastiaan Janssen''' on ''2016-08-02T14:45:57+02:00'' https://github.com/umbraco/Umbraco-CMS/commit/2df8f550324f014cb1fa326f6d219e1c757a8bd7

U4-8794 Allow Newtosoft JSON 9.0.1 to be installed

#U4-8794 Fixed


Harvey Williams 09 Aug 2016, 15:29:38

Just came across a bug with updating Newtonsoft JSON to version 9.0.0 when using Umbraco 7.4.1.

I attempted to sort some nodes in Umbraco, and the following error occued:

 2016-08-09 16:17:20,828 [P13420/D8/T630] ERROR umbraco.presentation.webservices.nodeSorter - Could not update content sort order
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue() in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\JsonTextReader.cs:line 1591
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter) in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 2216
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 193
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\JsonSerializer.cs:line 823
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\JsonConvert.cs:line 861
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in C:\Development\Releases\Json\Working\Newtonsoft.Json\Working-Signed\Src\Newtonsoft.Json\JsonConvert.cs:line 820
   at Our.Umbraco.NestedContent.PropertyEditors.NestedContentPropertyEditor.NestedContentPropertyValueEditor.ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
   at Umbraco.Core.PropertyEditors.PropertyValueEditor.ConvertDbToXml(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
   at Umbraco.Core.Services.EntityXmlSerializer.Serialize(IDataTypeService dataTypeService, Property property)
   at Umbraco.Core.Services.EntityXmlSerializer.Serialize(IDataTypeService dataTypeService, IContentBase contentBase, String nodeName)
   at Umbraco.Core.Services.EntityXmlSerializer.Serialize(IContentService contentService, IDataTypeService dataTypeService, IUserService userService, IContent content, Boolean deep)
   at Umbraco.Core.Services.PackagingService.Export(IContent content, Boolean deep, Boolean raiseEvents)
   at Umbraco.Web.Search.ExamineEvents.ReIndexForContent(IContent sender, Boolean isContentPublished)
   at Umbraco.Core.Cache.CacheRefresherBase`1.OnCacheUpdated(TInstanceType sender, CacheRefresherEventArgs args)
   at Umbraco.Core.Sync.ServerMessengerBase.DeliverLocal[T](ICacheRefresher refresher, MessageType messageType, Func`2 getId, IEnumerable`1 instances)
   at Umbraco.Core.Sync.ServerMessengerBase.Deliver[T](IEnumerable`1 servers, ICacheRefresher refresher, MessageType messageType, Func`2 getId, IEnumerable`1 instances)
   at Umbraco.Web.Cache.DistributedCache.Refresh[T](Guid factoryGuid, Func`2 getNumericId, T[] instances)
   at Umbraco.Web.Cache.DistributedCacheExtensions.RefreshUnpublishedPageCache(DistributedCache dc, IContent[] content)
   at Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e)
   at Umbraco.Core.Events.EventExtensions.RaiseEvent[TSender,TArgs](TypedEventHandler`2 eventHandler, TArgs args, TSender sender)
   at Umbraco.Core.Services.ContentService.Sort(IEnumerable`1 items, Int32 userId, Boolean raiseEvents)
   at umbraco.presentation.webservices.nodeSorter.SortContent(String[] ids, Int32 parentId)

This sorting error did not happen in other parts of Umbraco.

To solve the issue, I deleted any unpublished nodes in the tree that I was trying to sort. Each unpublished node brought up an Umbraco dialog with the same error.

After deleting all of the unpublished nodes, sorting then worked again.

I could not reproduce the error by unpublishing nodes and trying to sort.


Sebastiaan Janssen 23 Aug 2016, 08:49:06

This wasn't really fixed in 7.5.0 after all, the PR here does allow you to install json.net 9. https://github.com/umbraco/Umbraco-CMS/pull/1446


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.2

Sprint: Sprint 39

Story Points:

Cycle: