From 43d71b6ce89dce6144a1926664c6c13812c129b6 Mon Sep 17 00:00:00 2001 From: Jorge Ramirez Date: Thu, 27 Apr 2023 16:13:33 -0700 Subject: [PATCH] TextDisplayMenu switched to System.Text.Json --- .../Driver/BaseClasses/MenuItemBase.cs | 16 ++++++++-------- .../Driver/Displays.TextDisplayMenu.csproj | 2 +- .../Driver/TextDisplayMenu.cs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/BaseClasses/MenuItemBase.cs b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/BaseClasses/MenuItemBase.cs index a066c28b14..c17014afc9 100644 --- a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/BaseClasses/MenuItemBase.cs +++ b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/BaseClasses/MenuItemBase.cs @@ -1,47 +1,47 @@ -using Newtonsoft.Json; + +using System.Text.Json.Serialization; namespace Meadow.Foundation.Displays.UI { /// /// Represents a text display menu item /// - [JsonObject(MemberSerialization.OptIn)] public class MenuItem { /// /// Sub items in the menu /// - [JsonProperty("sub")] + [JsonPropertyName("sub")] public MenuItem[] SubItems { get; set; } /// /// The text on the menu item /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } /// /// The optional command when the item is selected /// - [JsonProperty("command")] + [JsonPropertyName("command")] public string Command { get; set; } /// /// The menu item type /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// The menu item id /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// The menu item value /// - [JsonProperty("value")] + [JsonPropertyName("value")] public object Value { get; set; } /// diff --git a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/Displays.TextDisplayMenu.csproj b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/Displays.TextDisplayMenu.csproj index 9412145386..81a0d23d1d 100644 --- a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/Displays.TextDisplayMenu.csproj +++ b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/Displays.TextDisplayMenu.csproj @@ -17,7 +17,7 @@ - + diff --git a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/TextDisplayMenu.cs b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/TextDisplayMenu.cs index 96c776f102..69ec074875 100644 --- a/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/TextDisplayMenu.cs +++ b/Source/Meadow.Foundation.Libraries_and_Frameworks/Displays.TextDisplayMenu/Driver/TextDisplayMenu.cs @@ -1,9 +1,9 @@ using Meadow.Foundation.Displays.UI.InputTypes; using Meadow.Peripherals.Displays; -using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; +using System.Text.Json; namespace Meadow.Foundation.Displays.UI { @@ -72,7 +72,7 @@ MenuItem[] ParseMenuData(byte[] menuJson) { var menuString = System.Text.Encoding.Default.GetString(menuJson); - return JsonConvert.DeserializeObject(menuString); + return JsonSerializer.Deserialize(menuString); } void Init(ITextDisplay display, MenuPage menuPage)