public static string ToJson <T>(T entity, bool format = true) { return(format // pretty or... ? JsonConvert.SerializeObject(entity, Formatting.Indented) // fast! : JsonSerializer.SerializeToString(entity)); }
private void ServiceStackBechmark <T>(T obj, int count) { return; try { long initlength = 0; Stopwatch sw; //----------------------------------- var sstSerializer = new ServiceStack.Text.JsonSerializer <T>(); var initSerialized = sstSerializer.SerializeToString(obj); initlength = initSerialized.Length; sstSerializer.DeserializeFromString(initSerialized); using (var sharperMem = new MemoryStream()) { sw = Stopwatch.StartNew(); for (int i = 0; i < count; i++) { sstSerializer.SerializeToString(obj); } } sw.Stop(); Log("ServiceStackText Serialize took: "+ ToString(sw.Elapsed) + " data-size: " + initlength); sw = Stopwatch.StartNew(); for (int i = 0; i < count; i++) { sstSerializer.DeserializeFromString(initSerialized); } sw.Stop(); Log("ServiceStackText Deserialize took: "+ ToString(sw.Elapsed)); } catch (Exception ex) { Log("ServiceStackText failed, " + ex.Message); } }
private async Task CreateCognitoSecretFileAsync() { foreach (var cognitoClient in this._configSettings.ExtraAWSConfig.CognitoClients) { cognitoClient.ClientSecret = await _awsCognitoHelper.GetClientSecretForAppClientAsync(cognitoClient) .ConfigureAwait(false); } await FileHelper.CreateFileWithContentAsync(Path.Combine(this._configSettings.SecretsDockerFolderPath, this._configSettings.ExtraAWSConfig.CognitoSecretsFileName), JsonSerializer.SerializeToString(this._configSettings.ExtraAWSConfig.CognitoClients)) .ConfigureAwait(false); }
public static string ToJson(this object obj) { return(JsonSerializer.SerializeToString(obj)); }
public string Serialize(object obj) { return(JsonSerializer.SerializeToString(obj)); }
public string ServiceStack_Serialize() { return(JsonSerializer.SerializeToString(RootSampleObject)); }
/// <summary> /// Serializes object to a string /// </summary> /// <param name="obj">Object to serialize</param> /// <returns>Serialized string of the object</returns> public string Serialize <T>(T obj) { return(Serializer.SerializeToString(obj)); }