Skip to content

Commit

Permalink
Parse quoted ints as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 18, 2021
1 parent 99739a1 commit dcae904
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Netkan/Extensions/YamlExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using log4net;
using YamlDotNet.Core;
using YamlDotNet.RepresentationModel;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -76,9 +77,11 @@ private static JValue ToJValue(this YamlScalarNode yaml)
case "null": return JValue.CreateNull();
case "true": return new JValue(true);
case "false": return new JValue(false);
default: return int.TryParse(yaml.Value, out int intVal)
? new JValue(intVal)
: new JValue(yaml.Value);
// Convert unquoted integers to int type
default: return yaml.Style == ScalarStyle.Plain
&& int.TryParse(yaml.Value, out int intVal)
? new JValue(intVal)
: new JValue(yaml.Value);
}
}

Expand Down

0 comments on commit dcae904

Please sign in to comment.