We have a project which both uses ServiceStack.Text and Newtonsoft.json. Now I want to migrate everything to yours. One class I have no clue, it has extension methods on Newtonsoft's method JsonTextWriter, example:
public static void Write(this JsonTextWriter jsonWriter, Overlay overlay)
if (overlay != null)
if (overlay is MarkerOverlay)
jsonWriter.Write(overlay as MarkerOverlay);
else if (overlay is PolylineOverlay)
jsonWriter.Write(overlay as PolylineOverlay);
else if (overlay is PolygonOverlay)
jsonWriter.Write(overlay as PolygonOverlay);
And of course the derived classes have again their specific writers.
What would be a ServiceStack implementation?
I’ve no idea what that’s for, but we don’t have anything like it. See the docs if custom serialisation of a struct.
The way you can customize how types are serialised is to use JsConfig APIs, e.g:
JsConfig<System.Drawing.Color>.SerializeFn = c => c.ToString().Replace("Color ","").Replace("[","").Replace("]","");
JsConfig<System.Drawing.Color>.DeSerializeFn = System.Drawing.Color.FromName;
JsConfig<Guid>.SerializeFn = guid => guid.ToString("D");
JsConfig<TimeSpan>.SerializeFn = time =>
(time.Ticks < 0 ? "-" : "") + time.ToString("hh':'mm':'ss'.'fffffff");
Okay thank you very much, I'll have a look and see if this is appropriate. The reason it is used this way for some classes extra information is written, like:
if (address is DutchAddress)
var dutchAddress = address as DutchAddress;