Created
April 27, 2012 02:22
-
-
Save chrisc24/2505152 to your computer and use it in GitHub Desktop.
messed up deserialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
using Newtonsoft.Json.Utilities; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string s = "{\"data\":{\"id\":1,\"first_name\":\"empT3\",\"last_name\":\"isAwesome\",\"email\":\"\",\"auth_token\":\"GUID\"}}"; | |
Authorization deserializedAuth = JsonConvert.DeserializeObject<AuthorizationLargeObject>(s); | |
Console.WriteLine(deserializedAuth.data.auth_token); | |
Console.ReadLine(); | |
} | |
} | |
class AuthorizationLargeObject | |
{ | |
public PointlessAuthorizationSubObject data | |
public AuthorizationLargeObject() | |
{ | |
} | |
} | |
class PointlessAuthorizationSubObject | |
{ | |
public int id; | |
public string first_name; | |
public string last_name; | |
public string email; | |
public string auth_token; | |
public PointlessAuthorizationSubObject() | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment