代码语言:javascript复制
string json = @"{
'时间': 44705.55820057871,
'泵车1流量': 0.195,
'泵车2压力': 3.6999008709572907,
'泵车2流量': 0.195,
'三参仪压力': 0.8756695025080155,
'三参仪总流量': 317.664,
'三参仪瞬时流量': 13.32,
'三参仪密度': 1.7328615188598633,
'流量总量': 376.588,
'参数总流量': 376.588,
'参数总流量显示': 376588.0,
'参数总流量修正': 0.0,
'压力': 3.6999008709572907
}";
var obj = Phycical.FromJson(json).Dump();
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public class Phycical
{
public static Dictionary<string, double> FromJson(string json) => JsonConvert.DeserializeObject<Dictionary<string, double>>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Dictionary<string, double> self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters = {
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}