CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string input = @"{
""DataKEY"": [
{
""value"": {
""timestamp"": ""2022-10-26T05:00:00Z"",
""value"": 0.0
}
},
{
""value"": {
""timestamp"": ""2022-10-26T06:00:00Z"",
""value"": 0.0
}
}
]
}";
//Console.WriteLine(input);
var objs = Newtonsoft.Json.JsonConvert.DeserializeObject<DataKeyWrapper>(input);
//FiddleHelper.Dump(objs);
var output = Newtonsoft.Json.JsonConvert.SerializeObject(objs, new Newtonsoft.Json.JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore });
Console.WriteLine(output);
}
public class DataKeyWrapper
{
public DataKey[] DataKEY { get;set; }
}
public class DataKey
{
public DataKeyValue Key { get;set; }
public DataKeyValue Value
{
get
{
return null;
}
set
{
Key = value;
}
}
}
public class DataKeyValue
{
public DateTime timestamp { get;set; }
public Decimal value { get;set; }
}
}