I'm a little bit lost with dynamic data and I will like your help. This is what I'm trying to do:
I have the following Classes:
public class SmsMessage : MessageCommonDefinition
{
public string MessageServiceKey { get; set; }
public string MessageAttachments { get; set; }
public bool MessageBodyUseTemplate { get; set; }
public string MessageBodyTemplate { get; set; }
public string MessageBodyTemplateValues { get; set; }
public bool ValidateWithCarrier { get; set; }
public bool IncludeCarrierInfo { get; set; }
}
public class EmailMessage : MessageCommonDefinition
{
public string MessageDisplayName { get; set; }
public string MessageCc { get; set; }
public string MessageBcc { get; set; }
public string MessageSubject { get; set; }
public bool MessageIsBodyHtml { get; set; }
public bool MessageBodyUseTemplate { get; set; }
public string MessageBodyTemplate { get; set; }
public string MessageBodyTemplateValues { get; set; }
public bool IsConfidential { get; set; }
public string MessageAttachments { get; set; }
public MailPriority MessagePriority { get; set; }
}
public abstract class MessageCommonDefinition
{
public Guid MessageId { get; set; }
public string CompanyCode { get; set; }
public string MessageCode { get; set; }
public string MessageChannelCode { get; set; }
public string MessageTo { get; set; }
public string MessageFrom { get; set; }
public string MessageBody { get; set; }
public string ChannelName { get; set; }
}
I also have a method to fill a template that receives, among other parameters, the type of message to fill the template (EmailMessage, SmSMessage, etc.)
This is the method:
if (triggerGroup.ToUpper().ToUpper() == AppSettingsKeys.External.ToString().ToUpper())
{
List<PassengerTemplateEntity> passengerTemplateEntity = ACARSRepository.GetPassengerTemplateValues(emailMessage.MessageId);
var passengerTemplateValues = DynamicClassBuilder.BuildObject();
foreach (PassengerTemplateEntity passengerTemplate in passengerTemplateEntity)
{
passengerTemplateValues.AddProperty(passengerTemplate.FieldName, passengerTemplate.FieldData);
}
message.Body = Smart.Format(File.ReadAllText(attFilePath), passengerTemplateValues);
message.Subject = emailMessage.IsConfidential ? SettingsManager.GetAppSettingValue(AppSettingsKeys.ConfidentialKey, "-secmsg-")
+ " " + Smart.Format(emailMessage.MessageSubject.Trim(), passengerTemplateValues) : Smart.Format(emailMessage.MessageSubject.Trim(), passengerTemplateValues);
}
else if (triggerGroup.ToUpper() == AppSettingsKeys.Internal.ToString().ToUpper())
{
alertTemplateValues = CoreRepository.GetExceptionMessage(emailMessage.MessageCode);
if (alertTemplateValues != null)
{
message.Body = Smart.Format(File.ReadAllText(attFilePath), alertTemplateValues);
message.Subject = Smart.Format(emailMessage.MessageSubject.Trim(), alertTemplateValues);
}
else
{
alertTemplateValues = CoreRepository.GetExceptionMessage("E127");
throw new ArgumentException(Smart.Format("BlackBox.{0}: [Exception Code: {1}] {2}", alertTemplateValues.ShortName, alertTemplateValues.ExceptionCode, alertTemplateValues.ExceptionMessage), "ExceptionMessageCode: " + emailMessage.MessageCode, new ArgumentException());
}
}
else
{
alertTemplateValues = CoreRepository.GetExceptionMessage("E123");
throw new ArgumentException(Smart.Format("BlackBox.{0}: [Exception Code: {1}] {2}", alertTemplateValues.ShortName, alertTemplateValues.ExceptionCode, alertTemplateValues.ExceptionMessage), "TriggerGroup: " + triggerGroup, new ArgumentException());
}
As you can see the method uses the emailMessage to retrieve values. What I want to achieve is to use this as a shared function. I want to send a generic parameter regardless it is an emailMessage or a SmsMessage and use the function by sending a generic object and fill the correct class with the correct value.
I'm using a class to get data from json to my main page and in my json i have an array i want to get them to my Main Page Here's my class code
class WeatherDays
{
public async static Task<day> GetWeather(double lat, double lon)
{
var http = new HttpClient();
var responce = await http.GetAsync("http://a3ane.com/omarNasar/d.php");
var result = await responce.Content.ReadAsStringAsync();
var serializer = new DataContractJsonSerializer(typeof(day));
var ms = new MemoryStream(Encoding.UTF8.GetBytes(result));
var data = (day)serializer.ReadObject(ms);
return data;
}
}
[DataContract]
public class Omarnasar
{
[DataMember]
public string w_id { get; set; }
[DataMember]
public string w_note_tody { get; set; }
[DataMember]
public string w_date { get; set; }
[DataMember]
public string w_time { get; set; }
[DataMember]
public string w_tody_one { get; set; }
[DataMember]
public string w_temperature_one { get; set; }
[DataMember]
public string w_humidity_one { get; set; }
[DataMember]
public string w_note_one { get; set; }
[DataMember]
public string w_tody_two { get; set; }
[DataMember]
public string w_temperature_two { get; set; }
[DataMember]
public string w_humidity_two { get; set; }
[DataMember]
public string w_note_two { get; set; }
[DataMember]
}
[DataContract]
public class day
{
[DataMember]
public List<Omarnasar> omarnasar { get; set; }
}
}
and my problem is i don't know how to get then to my main page using the task here's my try on MainPage
day week = await WeatherDays.GetWeather(20.0, 30.0);
temp1.Text = week.omarnasr.
I don't know how to use them can anyone help my !!!
I think this is what you want
StringBuilder sb = new StringBuilder();
foreach(var obj in week.omarnasr)
{
sb.Append(obj.w_temperature_one + " ");
}
temp1.Text = sb.ToString();
I have tried to parse the JSON string from Yahoo finance stock data from the below URL to CSV using various tools (JSON.NET, etc.,) available in internet.
MSFT Yahoo Data
I want to parse JSON string to CSV as below format.
Date | Open | High | Low | Close | Volume
Please any one help me to resolve this. Thanks in advance.
1) You need to define classes for Yahoo JSON schema: (Modified: Some values might be null. So, I have modified them as null-able variables)
public class Pre
{
public string timezone { get; set; }
public int end { get; set; }
public int start { get; set; }
public int gmtoffset { get; set; }
}
public class Regular
{
public string timezone { get; set; }
public int end { get; set; }
public int start { get; set; }
public int gmtoffset { get; set; }
}
public class Post
{
public string timezone { get; set; }
public int end { get; set; }
public int start { get; set; }
public int gmtoffset { get; set; }
}
public class CurrentTradingPeriod
{
public Pre pre { get; set; }
public Regular regular { get; set; }
public Post post { get; set; }
}
public class Meta
{
public string currency { get; set; }
public string symbol { get; set; }
public string exchangeName { get; set; }
public string instrumentType { get; set; }
public int firstTradeDate { get; set; }
public int gmtoffset { get; set; }
public string timezone { get; set; }
public string exchangeTimezoneName { get; set; }
public CurrentTradingPeriod currentTradingPeriod { get; set; }
public string dataGranularity { get; set; }
public List<string> validRanges { get; set; }
}
public class Quote
{
public List<object> volume { get; set; }
public List<double?> low { get; set; }
public List<double?> high { get; set; }
public List<double?> close { get; set; }
public List<double?> open { get; set; }
}
public class Unadjclose
{
public List<double?> unadjclose { get; set; }
}
public class Unadjquote
{
public List<double?> unadjopen { get; set; }
public List<double?> unadjclose { get; set; }
public List<double?> unadjhigh { get; set; }
public List<double?> unadjlow { get; set; }
}
public class Indicators
{
public List<Quote> quote { get; set; }
public List<Unadjclose> unadjclose { get; set; }
public List<Unadjquote> unadjquote { get; set; }
}
public class Result
{
public Meta meta { get; set; }
public List<int> timestamp { get; set; }
public Indicators indicators { get; set; }
}
public class Chart
{
public List<Result> result { get; set; }
public object error { get; set; }
}
public class RootObject
{
public Chart chart { get; set; }
}
2) You need to deserialize JSON into object
var str = wc.DownloadString("https://query1.finance.yahoo.com/v7/finance/chart/MSFT?range=25y&interval=1d&indicators=quote&includeTimestamps=true&includePrePost=false&corsDomain=finance.yahoo.com");
var data = JsonConvert.DeserializeObject<Rootobject>(str);
3) Then, iterate through this object and build your CSV. Working sample: (Modified: Some values might be null. So, I have modified the code to check if that null-able variables preserves value using HasValue property before converting to string)
var wc = new WebClient();
var str = wc.DownloadString("https://query1.finance.yahoo.com/v7/finance/chart/MSFT?range=25y&interval=1d&indicators=quote&includeTimestamps=true&includePrePost=false&corsDomain=finance.yahoo.com");
var data = JsonConvert.DeserializeObject<Rootobject>(str);
var result = new List<string>();
var quotesInfo = data.chart.result.First();
for (var i = 0; i < quotesInfo.timestamp.Count; i++)
{
var quotesStr = new List<string>();
var quoteData = quotesInfo.indicators.quote.First();
quotesStr.Add(UnixTimeStampToDateTime(quotesInfo.timestamp[i]).ToString(CultureInfo.InvariantCulture));
quotesStr.Add(quoteData.open[i].HasValue ? quoteData.open[i].ToString() : string.Empty);
quotesStr.Add(quoteData.high[i].HasValue ? quoteData.high[i].ToString() : string.Empty);
quotesStr.Add(quoteData.low[i].HasValue ? quoteData.low[i].ToString() : string.Empty);
quotesStr.Add(quoteData.close[i].HasValue ? quoteData.close[i].ToString() : string.Empty);
quotesStr.Add(quoteData.volume[i] != null ? quoteData.volume[i].ToString() : string.Empty);
result.Add(string.Join(",", quotesStr));
}
File.WriteAllLines("result.csv",result);
Modified: And, I have added the code to convert the timestamp to DateTime format.
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToUniversalTime();
return dtDateTime;
}
At the end you will receive comma delimeted CSV file
I make a request at wikipedia api to get 3 image url , so that I can use this picture in my code. I use the url https://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url&iiurlwidth=400&titles=File%3ALuftbild%20Flensburg%20Schleswig-Holstein%20Zentrum%20Stadthafen%20Foto%202012%20Wolfgang%20Pehlemann%20Steinberg-Ostsee%20IMG%206187.jpg%7CFile%3AHafen%20St%20Marien%20Flensburg2007.jpg%7CFile%3ANordertor%20im%20Schnee%20(Flensburg%2C%20Januar%202014).JPG to get three image. I got following json file from json2csharp.
public class Imageinfo
{
public string thumburl { get; set; }
public int thumbwidth { get; set; }
public int thumbheight { get; set; }
public string url { get; set; }
public string descriptionurl { get; set; }
}
public class Pageval1
{
public int ns { get; set; }
public string title { get; set; }
public string missing { get; set; }
public string imagerepository { get; set; }
public List<Imageinfo> imageinfo { get; set; }
}
public class Imageinfo2
{
public string thumburl { get; set; }
public int thumbwidth { get; set; }
public int thumbheight { get; set; }
public string url { get; set; }
public string descriptionurl { get; set; }
}
public class Pageval2
{
public int ns { get; set; }
public string title { get; set; }
public string missing { get; set; }
public string imagerepository { get; set; }
public List<Imageinfo2> imageinfo { get; set; }
}
public class Imageinfo3
{
public string thumburl { get; set; }
public int thumbwidth { get; set; }
public int thumbheight { get; set; }
public string url { get; set; }
public string descriptionurl { get; set; }
}
public class Pageval3
{
public int ns { get; set; }
public string title { get; set; }
public string missing { get; set; }
public string imagerepository { get; set; }
public List<Imageinfo3> imageinfo { get; set; }
}
public class Pages
{
public List<Pageval1> pageval1 { get; set; }
public List<Pageval2> pageval2 { get; set; }
public List<Pageval3> pageval3 { get; set; }
}
class Image
{
public static PictureBox Image1 = new PictureBox();
public static PictureBox Image2 = new PictureBox();
public static PictureBox Image3 = new PictureBox();
public static void Load_Image1()
{
using (WebClient wc = new WebClient())
{
var client = new WebClient();
var uri = ("https://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url&iiurlwidth=400&titles=File%3ALuftbild%20Flensburg%20Schleswig-Holstein%20Zentrum%20Stadthafen%20Foto%202012%20Wolfgang%20Pehlemann%20Steinberg-Ostsee%20IMG%206187.jpg%7CFile%3AHafen%20St%20Marien%20Flensburg2007.jpg%7CFile%3ANordertor%20im%20Schnee%20(Flensburg%2C%20Januar%202014).JPG");
var response = client.DownloadString(new Uri(uri));
var responseJson = JsonConvert.DeserializeObject<RootObject>(response);
var firstKey1 = responseJson.query.pages.First().Key;
string image1 = responseJson.query.pages[firstKey1].pageval1.First().imageinfo.First().thumburl;
String image2 = responseJson.query.pages[firstKey1].pageval2.First().imageinfo.First().thumburl;
String image3 = responseJson.query.pages[firstKey1].pageval3.First().imageinfo.First().thumburl;
Image1.SizeMode = PictureBoxSizeMode.StretchImage;
Image2.SizeMode = PictureBoxSizeMode.StretchImage;
Image3.SizeMode = PictureBoxSizeMode.StretchImage;
Image1.LoadAsync(image1);
Image2.LoadAsync(image2);
Image3.LoadAsync(image3);
}
}
}
}
I want to get the thumburl from every imageinfo.But I am not sure how to proceed with these classes to serialize json and then get the image.
I assume the thing you struggling with is how to handle those invalid classes. Well the issue that is happening is that -1, -2, -3 are not valid as C# identifiers so it is unable to create classes for those items.
Since for this case they need to be dynamic we can solve this issue by using a dictionary for the pages element.
Note that I am using Json.Net so you will want to install that via Nuget.
string url = #"https://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url&iiurlwidth=400&titles=File%3ALuftbild%20Flensburg%20Schleswig-Holstein%20Zentrum%20Stadthafen%20Foto%202012%20Wolfgang%20Pehlemann%20Steinberg-Ostsee%20IMG%206187.jpg|File%3AHafen%20St%20Marien%20Flensburg2007.jpg|File%3ANordertor%20im%20Schnee%20%28Flensburg%2C%20Januar%202014%29.JPG";
// i'll leave it up to you to do any null and error checking
using (var client = new WebClient())
{
var text = client.DownloadString(url);
var result = JsonConvert.DeserializeObject<RootObject>(text);
foreach (var page in result.Query.Pages)
{
foreach (var imageInfo in page.Value.ImageInfo)
{
Console.WriteLine("{0}: {1}", page.Value.Title, imageInfo.ThumbUrl);
}
}
}
// the relevant classes for deserialization
public class RootObject
{
public string BatchComplete { get; set; }
public Query Query { get; set; }
}
public class Query
{
// this is how you can deal with those invalid identifiers
// the -1, -2, -3 will be placed as keys inside this dictionary
public Dictionary<string, Page> Pages { set; get; }
}
public class Page
{
public int Ns { get; set; }
public string Title { get; set; }
public string Missing { get; set; }
public string ImageRepository { get; set; }
public List<ImageInfo> ImageInfo { get; set; }
}
public class ImageInfo
{
public string ThumbUrl { get; set; }
public int ThumbWidth { get; set; }
public int ThumbHeight { get; set; }
public string Url { get; set; }
public string DescriptionUrl { get; set; }
}
The output will be:
File:Luftbild Flensburg Schleswig-Holstein Zentrum Stadthafen Foto 2012 Wolfgang Pehlemann Steinberg-Ostsee IMG 6187.jpg: https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Luftbild_Flensburg_Schleswig-Holstein_Zentrum_Stadthafen_Foto_2012_Wolfgang_Pehlemann_Steinberg-Ostsee_IMG_6187.jpg/400px-Luftbild_Flensburg_Schleswig-Holstein_Zentrum_Stadthafen_Foto_2012_Wolfgang_Pehlemann_Steinberg-Ostsee_IMG_6187.jpg
File:Hafen St Marien Flensburg2007.jpg: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Hafen_St_Marien_Flensburg2007.jpg/400px-Hafen_St_Marien_Flensburg2007.jpg
File:Nordertor im Schnee (Flensburg, Januar 2014).JPG: https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Nordertor_im_Schnee_%28Flensburg%2C_Januar_2014%29.JPG/400px-Nordertor_im_Schnee_%28Flensburg%2C_Januar_2014%29.JPG
Im new in developing windows phone app --> i have problem so i have tried all the possible solutions but with no vain:-
the application tried to take result from webservice the result come back like this:-
{"d":"{\"sessionid\":null,\"VersionInfo\":{\"Rel\":0,\"Ver\":0,\"Patch\":0,\"ForceUpdate\":0,\"UpdateType\":0,\"Globals\":{\"MultiSessionsAllowed\":true,\"CommCalcType\":1,\"PriceChangedTimer\":20,\"ValidLotsLocation\":2,\"CustumizeTradeMsg\":true,\"FirstWhiteLabeledOffice\":null,\"DealerTreePriv\":0,\"ClientConnectTimer\":200,\"ClientTimeoutTimer\":500,\"DefaultLots\":0.01,\"WebSecurityID\":\"agagag\",\"ServerGMT\":3}},\"SystemLockInfo\":{\"MinutesRemaining\":0,\"HoursRemaining\":0,\"DaysRemaining\":0,\"Maintanance\":0,\"WillBeLocked\":1},\"FirstWhiteLabel\":\"HS Dev\",\"WLID\":\"3\",\"CheckWhiteLabel\":true,\"Password\":\"1234\",\"Username\":\"obeidat\",\"LastTickTime\":\"\/Date(1396613678728)\/\",\"SelectedAccount\":12345791,\"Name\":0,\"CompanyName\":\"HS Dev\",\"UserId\":579,\"DemoClient\":\"0\",\"FName\":\"obeidat\",\"SName\":null,\"TName\":null,\"LName\":null,\"Sms\":null,\"isReadOnly\":\"0\",\"SchSms\":\"0\",\"AlertSms\":\"0\",\"Temp\":null,\"GMTOffset\":\"5\",\"SvrGMT\":\"3\",\"ClientType\":null,\"EnableNews\":\"0\",\"PublicSlideNews\":\"\",\"PrivateSlideNews\":\"Thanks for using our platform##We will inform you here with any private news\",\"DealerTreePriv\":1}"}
so i have tried to parse it but it give me errors after that i have tried locally removed the {"d":" and \"LastTickTime\":\"\/Date(1396613678728)\/\" from the string with no connection to webservice and its working fine i use this code :-
// Constructor
public MainPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
//Json classes
public class OuterRootObject
{
public string d { get; set; }
}
public class Globals
{
public bool MultiSessionsAllowed { get; set; }
public int CommCalcType { get; set; }
public int PriceChangedTimer { get; set; }
public int ValidLotsLocation { get; set; }
public bool CustumizeTradeMsg { get; set; }
public object FirstWhiteLabeledOffice { get; set; }
public int DealerTreePriv { get; set; }
public int ClientConnectTimer { get; set; }
public int ClientTimeoutTimer { get; set; }
public double DefaultLots { get; set; }
public string WebSecurityID { get; set; }
public int ServerGMT { get; set; }
}
public class VersionInfo
{
public int Rel { get; set; }
public int Ver { get; set; }
public int Patch { get; set; }
public int ForceUpdate { get; set; }
public int UpdateType { get; set; }
public Globals Globals { get; set; }
}
public class SystemLockInfo
{
public int MinutesRemaining { get; set; }
public int HoursRemaining { get; set; }
public int DaysRemaining { get; set; }
public int Maintanance { get; set; }
public int WillBeLocked { get; set; }
}
public class RootObject
{
public string sessionid { get; set; }
public VersionInfo VersionInfo { get; set; }
public SystemLockInfo SystemLockInfo { get; set; }
public string FirstWhiteLabel { get; set; }
public string WLID { get; set; }
public bool CheckWhiteLabel { get; set; }
public string Password { get; set; }
public string Username { get; set; }
public DateTime LastTickTime { get; set; }
public int SelectedAccount { get; set; }
public int Name { get; set; }
public object ServicePath { get; set; }
public string GWSessionID { get; set; }
public string IP { get; set; }
public string SessionDateStart { get; set; }
public string CompanyName { get; set; }
public string UserId { get; set; }
public string DemoClient { get; set; }
public string FName { get; set; }
public string SName { get; set; }
public string TName { get; set; }
public string LName { get; set; }
public object Sms { get; set; }
public string isReadOnly { get; set; }
public string SchSms { get; set; }
public string AlertSms { get; set; }
public object Temp { get; set; }
public string GMTOffset { get; set; }
public string SvrGMT { get; set; }
public object ClientType { get; set; }
public string EnableNews { get; set; }
public string PublicSlideNews { get; set; }
public string PrivateSlideNews { get; set; }
public int DealerTreePriv { get; set; }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var jsonString =
"{\"sessionid\":null,\"VersionInfo\":{\"Rel\":0,\"Ver\":0,\"Patch\":0,\"ForceUpdate\":0,\"UpdateType\":0,\"Globals\":{\"MultiSessionsAllowed\":true,\"CommCalcType\":1,\"PriceChangedTimer\":20,\"ValidLotsLocation\":2,\"CustumizeTradeMsg\":true,\"FirstWhiteLabeledOffice\":null,\"DealerTreePriv\":0,\"ClientConnectTimer\":200,\"ClientTimeoutTimer\":500,\"DefaultLots\":0.01,\"WebSecurityID\":\"agagag\",\"ServerGMT\":3}},\"SystemLockInfo\":{\"MinutesRemaining\":0,\"HoursRemaining\":0,\"DaysRemaining\":0,\"Maintanance\":0,\"WillBeLocked\":1},\"FirstWhiteLabel\":\"HS Dev\",\"WLID\":\"3\",\"CheckWhiteLabel\":true,\"Password\":\"1234\",\"Username\":\"obeidat\",\"SelectedAccount\":12345791,\"Name\":0,\"CompanyName\":\"HS Dev\",\"UserId\":-579,\"DemoClient\":\"0\",\"FName\":\"obeidat\",\"SName\":null,\"TName\":null,\"LName\":null,\"Sms\":null,\"isReadOnly\":\"0\",\"SchSms\":\"0\",\"AlertSms\":\"0\",\"Temp\":null,\"GMTOffset\":\"5\",\"SvrGMT\":\"3\",\"ClientType\":null,\"EnableNews\":\"0\",\"PublicSlideNews\":\"\",\"PrivateSlideNews\":\"Thanks for using our platform##We will inform you here with any private news\",\"DealerTreePriv\":1}";
RootObject jsonObject = JsonConvert.DeserializeObject<RootObject>(jsonString);
MessageBox.Show("hello " + jsonObject.Username + "" + jsonObject.UserId);
int val1 = Convert.ToInt16(jsonObject.UserId);
if (val1 > 0)
MessageBox.Show("You are logedin");
else
{
MessageBox.Show("Sorry Please login");
}
}
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
}
}
Please help me to parse all of the json result (locally i mean without conection to web)and what is the code to do that.
thank you all
First, your JSON is all a string property of "D". You can't deserialize it to RootClass. Second, your JSON contains invalid escape characters in the LastTickTime area. I removed both of these, and the JSON parses without errors of any kind. I just used a console app to test it.
var s = "{\"sessionid\":null,\"VersionInfo\":{\"Rel\":0,\"Ver\":0,\"Patch\":0,\"ForceUpdate\":0,\"UpdateType\":0,\"Globals\":{\"MultiSessionsAllowed\":true,\"CommCalcType\":1,\"PriceChangedTimer\":20,\"ValidLotsLocation\":2,\"CustumizeTradeMsg\":true,\"FirstWhiteLabeledOffice\":null,\"DealerTreePriv\":0,\"ClientConnectTimer\":200,\"ClientTimeoutTimer\":500,\"DefaultLots\":0.01,\"WebSecurityID\":\"agagag\",\"ServerGMT\":3}},\"SystemLockInfo\":{\"MinutesRemaining\":0,\"HoursRemaining\":0,\"DaysRemaining\":0,\"Maintanance\":0,\"WillBeLocked\":1},\"FirstWhiteLabel\":\"HS Dev\",\"WLID\":\"3\",\"CheckWhiteLabel\":true,\"Password\":\"1234\",\"Username\":\"obeidat\",\"SelectedAccount\":12345791,\"Name\":0,\"CompanyName\":\"HS Dev\",\"UserId\":579,\"DemoClient\":\"0\",\"FName\":\"obeidat\",\"SName\":null,\"TName\":null,\"LName\":null,\"Sms\":null,\"isReadOnly\":\"0\",\"SchSms\":\"0\",\"AlertSms\":\"0\",\"Temp\":null,\"GMTOffset\":\"5\",\"SvrGMT\":\"3\",\"ClientType\":null,\"EnableNews\":\"0\",\"PublicSlideNews\":\"\",\"PrivateSlideNews\":\"Thanks for using our platform##We will inform you here with any private news\",\"DealerTreePriv\":1}";
var foo = JsonConvert.DeserializeObject<RootObject>(s);
Console.WriteLine(foo.UserId); // Writes 579
UPDATE
If you have no control over what you get back, do the following:
Take the response and get rid of the / combination. As such:
string webResponse = "your long web response from the server";
webResponse = webResponse.Replace(#"\/", "/");
// If dynamic isn't in the phone subset, you'll need a class here containing "d" as a string.
var jsonOuter = JsonConvert.DeserializeObject<dynamic>(webResponse);
var jsonInner = JsonConvert.DeserializeObject<RootObject>(jsonOuter.d);
if (jsonInner.UserId > .....)