[英]How to remove the endpoint of format=json using Servicestack v3
[英]How to get ServiceStack to format Guids with dashes when using JSON?
使用ServiceStack從Post返回一個簡單的User對象。
用戶對象非常簡單:
public class User
{
public Guid Id { get; set; }
public string Username { get; set; }
}
帖子方法:
public override object OnPost(User user)
{
User newUser;
// Do stuff to user...
return newUser;
}
我的問題是ServiceStack沒有破折號格式化Guid,所以JSON響應看起來像這樣:
{"id":"c884ce020ec94c65a8788c2ddc500434","username":"new user name"}
客戶端是Android / Java客戶端,UUID.fromString()方法對此格式感到不滿。
有沒有辦法強制ServiceStack返回用破折號格式化的Guid?
你可以覆蓋你的Guid序列化器
ServiceStack.Text.JsConfig<Guid>.SerializeFn = guid => guid.ToString();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.