Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created February 28, 2019 13:30
Show Gist options
  • Save jskeet/0edb911cfd98ce22ae7d3b905a18b25b to your computer and use it in GitHub Desktop.
Save jskeet/0edb911cfd98ce22ae7d3b905a18b25b to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace TestApp
{
class Program
{
static void Main()
{
string json = "{ \"expiry\":1551354842.0 }";
var jsonSerializer = new JavaScriptSerializer();
var data = jsonSerializer.Deserialize<Dictionary<string, object>>(json);
object exp;
data.TryGetValue("expiry", out exp);
Console.WriteLine(exp);
Console.WriteLine(exp.GetType());
var tempExpiry = long.Parse(exp.ToString());
Console.WriteLine(tempExpiry);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment