danielcrenna/tweetsharp — Issue #18: TwitterGeoConverter serialisation
Author: slodge
Created: 2012-01-28 02:25:33+00:00
State: open

Hi

Sorry I'm not doing this as a Pull... but my Fork's seriously broken at the moment (sorry!)

I just wanted to let you know that we've fixed up:

https://github.com/danielcrenna/tweetsharp/blob/master/src/net40/TweetSharp.Next/Serialization/Converters/TwitterGeoConverter.cs

so that it now looks like:

```

public class TwitterGeoConverter : TwitterConverterBase
{
//private const string GeoTemplate = "\"geo\":{{\"type\":\"Point\",\"coordinates\":[{0}, {1}]}}";
private const string GeoTemplate = "[{0}, {1}]";

///

/// Writes the JSON.
///

/// The writer.
/// The value.
/// The serializer.
public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
{
if (!(value is TwitterGeoLocation.GeoCoordinates))
{
return;
}

var location = (TwitterGeoLocation.GeoCoordinates)value;
var latitude = location.Latitude.ToString(CultureInfo.InvariantCulture);
var longitude = location.Longitude.ToString(CultureInfo.InvariantCulture);
var json = string.Format(GeoTemplate, latitude, longitude);
writer.WriteRawValue(json);
}
```

which works for write as well as read

Hope that helps!

Stuart