Utilizzo di ServiceStack per restituire un oggetto Utente semplice da un post.Come ottenere ServiceStack per formattare i Guids con trattini quando si usa JSON?
L'oggetto utente è piuttosto semplice:
public class User
{
public Guid Id { get; set; }
public string Username { get; set; }
}
il metodo POST:
public override object OnPost(User user)
{
User newUser;
// Do stuff to user...
return newUser;
}
Il mio problema è che ServiceStack formatta il Guid senza trattini, in modo che la risposta JSON sembra per esempio in questo modo:
{"id":"c884ce020ec94c65a8788c2ddc500434","username":"new user name"}
Il client è un client Android/Java e il metodo UUID.fromString() non arrabbiarsi su questo formato.
Esiste un modo per forzare ServiceStack a restituire una guida formattata con trattini?
FYI, è necessario eseguire l'override Guid? anche se vuoi che la stessa serializzazione avvenga per i nullable Guids. –
usando ToString ("D") più meglio, http://msdn.microsoft.com/en-us/library/97af8hh4.aspx –
@LiuPeng: Non c'è 'ToString (formato stringa)' per 'Guid?' (any' Nullable ') –
wqw