Skip to content

Commit

Permalink
修复bug:导入整数如"1",在json中会变成"1.0"的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yomunsam committed Aug 13, 2020
1 parent 73a6af0 commit 9165fe3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions NekoSheet/Utils/NekoUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public static JProperty GetJsonProperty(string propertyName, string content, Fie
case FieldType.String:
return new JProperty(propertyName, content);
case FieldType.Number:
if (int.TryParse(content, out int i_value))
return new JProperty(propertyName, i_value);
if(double.TryParse(content,out double d_value))
return new JProperty(propertyName, d_value);
else
Expand Down Expand Up @@ -191,6 +193,9 @@ private static object GetValueOrDefault(string content, FieldType type)
case FieldType.String:
return content;
case FieldType.Number:
if (int.TryParse(content, out int i_value))
return i_value;

if (double.TryParse(content, out double d_value))
return d_value;
else
Expand Down

0 comments on commit 9165fe3

Please sign in to comment.