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
120 changes: 118 additions & 2 deletions PCAxis.Serializers/JsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -180,4 +182,118 @@
#endregion

}


public class TableResponse
{


public TableResponse()
{

Columns = new List<TableResponseColumn>();
Comments = new List<TableResponseComment>();
Data = new List<TableResponseData>();
Metadata = new List<TableResponseMetadata>();
}

[JsonProperty("columns")]
public List<TableResponseColumn> Columns { get; set; }

[JsonProperty("comments")]
public List<TableResponseComment> Comments { get; set; }

[JsonProperty("data")]
public List<TableResponseData> Data { get; set; }

[JsonProperty("metadata")]
public List<TableResponseMetadata> 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<string>();
}

[JsonProperty("key")]
public List<string> Key { get; set; }

[JsonProperty("values")]
public List<string> Values { get; set; }

[JsonProperty("comments", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<string> 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(); }

Check warning on line 271 in PCAxis.Serializers/JsonSerializer.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a format provider when parsing date and time.

See more on https://sonarcloud.io/project/issues?id=PxTools_PCAxis.Serializers&issues=AZ__ihZTNHe142DXVHWv&open=AZ__ihZTNHe142DXVHWv&pullRequest=213
}

[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<T>(string data)
{
return JsonConvert.DeserializeObject<T>(data);
}
}
}
1 change: 0 additions & 1 deletion PCAxis.Serializers/PCAxis.Serializers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<PackageReference Include="Parquet.Net" Version="4.25.0" />
<PackageReference Include="PCAxis.Core" Version="1.3.0" />
<PackageReference Include="PCAxis.Metadata" Version="1.0.5" />
<PackageReference Include="PCAxis.Query" Version="1.0.10" />
<PackageReference Include="ClosedXML" Version="0.97.0" />
<PackageReference Include="PxWeb.Api2.Server.Models" Version="2.3.2" />
<PackageReference Include="Snappier" Version="1.3.1" />
Expand Down