Failed to deserialize double on wp7.

66 views
Skip to first unread message

Andreas Karlsson

unread,
May 1, 2012, 4:43:40 PM5/1/12
to RestSharp
After some fun time debugging I found that restsharp internally caught
an exception regarding parsing of double type when deserializing the
following json:

{"d" [{"__type": "OGT.ServiceAgents.Rebus.StopAreaDisplay",
"Priority": 0,
"Id": 1086,
"Name": "Smaragden",
"Lat": 58.57402938561677,
"Long": 16.171089786708613}]}

into the following class:

public class D
{
public string __type { get; set; }
public int Priority { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public double Lat { get; set; }
public double Long { get; set; }
}

Changing the double data type in the class to String makes everything
work.

I'm developing for wp7.1 and using RestSharp.103.1.0-beta.

Just thought I let you guys know!

John Sheehan

unread,
May 5, 2012, 1:58:39 AM5/5/12
to rest...@googlegroups.com
What was the exception?

tor...@programplatsen.se

unread,
May 31, 2012, 5:47:06 AM5/31/12
to RestSharp
Stumbled upon the samt issue today and the exception I get is a
FormatException at parsing a Double. My environment is an app for WP7
on Swedish regional settings.

If changing regional settings on the phone to "en-US" it happily parse
doubles in the json response, however running under other cultures
where the double separator would be different than "." the parsing
throws.
Found https://github.com/restsharp/RestSharp/blob/master/RestSharp/Deserializers/JsonDeserializer.cs
and I see no double parsing there.

/Torulf
Reply all
Reply to author
Forward
0 new messages