Skip to content

Commit

Permalink
Merge pull request #648 from WildernessLabs/textdisplaymenu-json-update
Browse files Browse the repository at this point in the history
TextDisplayMenu switched to System.Text.Json
  • Loading branch information
adrianstevens authored Apr 27, 2023
2 parents 89c318a + 43d71b6 commit 824d58d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
using Newtonsoft.Json;

using System.Text.Json.Serialization;

namespace Meadow.Foundation.Displays.UI
{
/// <summary>
/// Represents a text display menu item
/// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class MenuItem
{
/// <summary>
/// Sub items in the menu
/// </summary>
[JsonProperty("sub")]
[JsonPropertyName("sub")]
public MenuItem[] SubItems { get; set; }

/// <summary>
/// The text on the menu item
/// </summary>
[JsonProperty("text")]
[JsonPropertyName("text")]
public string Text { get; set; }

/// <summary>
/// The optional command when the item is selected
/// </summary>
[JsonProperty("command")]
[JsonPropertyName("command")]
public string Command { get; set; }

/// <summary>
/// The menu item type
/// </summary>
[JsonProperty("type")]
[JsonPropertyName("type")]
public string Type { get; set; }

/// <summary>
/// The menu item id
/// </summary>
[JsonProperty("id")]
[JsonPropertyName("id")]
public string Id { get; set; }

/// <summary>
/// The menu item value
/// </summary>
[JsonProperty("value")]
[JsonPropertyName("value")]
public object Value { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>
<ItemGroup>
<None Include="..\..\..\icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<ProjectReference Include="..\..\Graphics.MicroGraphics\Driver\Graphics.MicroGraphics.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -72,7 +72,7 @@ MenuItem[] ParseMenuData(byte[] menuJson)
{
var menuString = System.Text.Encoding.Default.GetString(menuJson);

return JsonConvert.DeserializeObject<MenuItem[]>(menuString);
return JsonSerializer.Deserialize<MenuItem[]>(menuString);
}

void Init(ITextDisplay display, MenuPage menuPage)
Expand Down

0 comments on commit 824d58d

Please sign in to comment.