Skip to content

Instantly share code, notes, and snippets.

@brunomlopes
Last active January 4, 2016 09:09
Show Gist options
  • Save brunomlopes/8600424 to your computer and use it in GitHub Desktop.
Save brunomlopes/8600424 to your computer and use it in GitHub Desktop.
internal class A
{
public string uid { get; set; }
}
public static class Class1
{
public static void Run()
{
var regexp = new Regex(@"'uid':\s*(?<uid>[0-9]{8}[0-9]+)\s*", RegexOptions.Multiline);
var value = @"
{
'uid': 200532601548057346057920392776 }";
value = regexp.Replace(value, "'uid':'$1'");
var a = JsonConvert.DeserializeObject<A>(value);
Debug.Assert(a.uid == "200532601548057346057920392776");
value = @"
{
'uid': 200532 }";
value = regexp.Replace(value, "'uid':'$1'");
a = JsonConvert.DeserializeObject<A>(value);
Debug.Assert(a.uid == "200532");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment