I am writing results i return from stored procedure into json. I did it but i am not sure if there is a simpler cleaner way other than what i have. Also how can i check that it really wrote to json?
var results = mySvc.GetInfo("Environment");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
JsonWriter jsonWriter = new JsonTextWriter(sw);
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("Id");
jsonWriter.WriteValue(results.Id);
jsonWriter.WritePropertyName("Head");
jsonWriter.WriteValue(results.Head);
jsonWriter.WritePropertyName("Value");
jsonWriter.WriteValue(results.Value);
jsonWriter.WritePropertyName("GuidTwo");
jsonWriter.WriteValue(results.GuidTwo);
jsonWriter.WritePropertyName("GuidOne");
jsonWriter.WriteValue(results.Guid1);
jsonWriter.WriteEndObject();
return results;