From c32aba9129155270630d6a3c91f51099f9874220 Mon Sep 17 00:00:00 2001 From: likp Date: Fri, 14 Aug 2026 11:02:35 +0200 Subject: [PATCH] Added classes from `PCAxis.Query` that `JsonSerializer` was dependent on and removed the nuget dependency. --- PCAxis.Serializers/JsonSerializer.cs | 120 ++++++++++++++++++- PCAxis.Serializers/PCAxis.Serializers.csproj | 1 - 2 files changed, 118 insertions(+), 3 deletions(-) diff --git a/PCAxis.Serializers/JsonSerializer.cs b/PCAxis.Serializers/JsonSerializer.cs index b64921e..39cd09b 100644 --- a/PCAxis.Serializers/JsonSerializer.cs +++ b/PCAxis.Serializers/JsonSerializer.cs @@ -1,12 +1,14 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using Newtonsoft.Json; + using PCAxis.Paxiom; using PCAxis.Paxiom.Extensions; using PCAxis.Paxiom.Operations; -using PCAxis.Query; namespace PCAxis.Serializers { @@ -180,4 +182,118 @@ private PXModel RearrangeValues(PXModel model) #endregion } + + + public class TableResponse + { + + + public TableResponse() + { + + Columns = new List(); + Comments = new List(); + Data = new List(); + Metadata = new List(); + } + + [JsonProperty("columns")] + public List Columns { get; set; } + + [JsonProperty("comments")] + public List Comments { get; set; } + + [JsonProperty("data")] + public List Data { get; set; } + + [JsonProperty("metadata")] + public List Metadata { get; set; } + } + + public class TableResponseColumn + { + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("text")] + public string Text { get; set; } + + [JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Comment { get; set; } + + [JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Type { get; set; } + + [JsonProperty("unit", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Unit { get; set; } + } + + public class TableResponseComment + { + [JsonProperty("variable")] + public string Variable { get; set; } + + [JsonProperty("value")] + public string Value { get; set; } + + [JsonProperty("comment")] + public string Comment { get; set; } + } + + public class TableResponseData + { + public TableResponseData() + { + Values = new List(); + } + + [JsonProperty("key")] + public List Key { get; set; } + + [JsonProperty("values")] + public List Values { get; set; } + + [JsonProperty("comments", DefaultValueHandling = DefaultValueHandling.Ignore)] + public List Comments { get; set; } + } + + public class TableResponseMetadata + { + private DateTime _updated; + + [JsonProperty("infofile")] + public string Infofile { get; set; } + + [JsonProperty("updated")] + public string Updated + { + get { return _updated.ToString("yyyy-MM-ddTHH:mm:ssZ"); } + set { _updated = DateTime.Parse(value).ToUniversalTime(); } + } + + [JsonProperty("label")] + public string Label { get; set; } + + [JsonProperty("source")] + public string Source { get; set; } + + + } + public static class JsonHelper + { + private static string SerializeJson(object obj, bool prettyPrint) + { + return JsonConvert.SerializeObject(obj, prettyPrint ? Formatting.Indented : Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + } + + public static string ToJSON(this object obj, bool prettyPrint) + { + return SerializeJson(obj, prettyPrint); + } + + public static object Deserialize(string data) + { + return JsonConvert.DeserializeObject(data); + } + } } diff --git a/PCAxis.Serializers/PCAxis.Serializers.csproj b/PCAxis.Serializers/PCAxis.Serializers.csproj index 82c5a00..37fea93 100644 --- a/PCAxis.Serializers/PCAxis.Serializers.csproj +++ b/PCAxis.Serializers/PCAxis.Serializers.csproj @@ -30,7 +30,6 @@ -