Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanb Gao committed Jul 5, 2019
1 parent 5cd4997 commit 8fde502
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
4 changes: 2 additions & 2 deletions ECharts/ECharts.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>Based on ECharts(https://echarts.baidu.com/echarts2/doc/doc.html) tool library,support .NET Framework and .NET Core</Description>
<AssemblyName>ECharts.Net</AssemblyName>
<RootNamespace>ECharts.Net</RootNamespace>
<Version>1.0.8</Version>
<Version>1.0.9</Version>
<PackageProjectUrl>https://xhanb.github.io/ECharts.Net/</PackageProjectUrl>
<RepositoryUrl>https://github.com/xhanb/ECharts.Net</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -19,7 +19,7 @@
<PackageIconUrl>https://raw.githubusercontent.com/xhanb/ECharts.Net/master/ECharts/logo.png</PackageIconUrl>
<DocumentationFile>D:\Projects\ECharts\ECharts\ECharts.Net.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions ECharts/ECharts.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 4 additions & 17 deletions ECharts/JsonHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Formatting = System.Xml.Formatting;

namespace ECharts.Net
Expand All @@ -20,26 +19,14 @@ public static string ToJson(this object obj)
var op = new System.Text.Json.Serialization.JsonSerializerOptions { IgnoreNullValues = true, WriteIndented = true };
return System.Text.Json.Serialization.JsonSerializer.ToString(obj, op);
#else
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var json = JsonConvert.SerializeObject(obj, (Newtonsoft.Json.Formatting)Formatting.Indented, jSetting);
var data = JsonConvert.DeserializeObject(json, typeof(object), jSetting);
var jSetting = new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore };
var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj, (Newtonsoft.Json.Formatting)Formatting.Indented, jSetting);
var data = Newtonsoft.Json.JsonConvert.DeserializeObject(json, typeof(object), jSetting);
var timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "yyyy'-'MM'-'dd hh:mm" };
json = JsonConvert.SerializeObject(data, (Newtonsoft.Json.Formatting)Formatting.Indented, timeConverter);
json = Newtonsoft.Json.JsonConvert.SerializeObject(data, (Newtonsoft.Json.Formatting)Formatting.Indented, timeConverter);
return json;
#endif

}

/// <summary>
/// json字符串数组转换为List
/// </summary>
/// <param name="str">json字符串数组</param>
/// <returns></returns>
public static List<string> JsonToList(this string str)
{
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include };
var data = JsonConvert.DeserializeObject(str, typeof(List<string>), jSetting) as List<string>;
return data;
}
}
}

0 comments on commit 8fde502

Please sign in to comment.