Although this won't solve your problem, string + string is a bad practice. It is better to use a StringBuilder:
var sb = new StringBuilder(); sb.AppendLine(Name); sb.AppendLine(Unit); sb.AppendLine(AddressLine1); sb.AppendLine(AddressLine2); sb.AppendLine(AddressLine3); sb.AppendLine(AddressLine4); sb.AppendLine(City); sb.AppendLine(State); sb.AppendLine(PostCode); sb.AppendLine(Country); return sb.ToString(); On Wed, Jun 27, 2012 at 11:45 PM, Terry151151 <te...@terry-watts.com> wrote: > I have a class that overrides ToString() to convert the class to a string. > Ie: > > public override string ToString() > { > if( Id == -1 ) > return ""; > else > return Name + "\n" + Unit > + "\n" + AddressLine1 + "\n" + AddressLine2 + "\n" + > AddressLine3 + > "\n" + AddressLine4 > + "\n" + City + "\n" + State + "\n" + PostCode + "\n" + > Country; > } > > I then I add the string to a JsonObject . > > JsonObject JObject = new JsonObject(); > JObject.Add( "Address", TheClass.ToString() ); > > When I generate the Json string using JsonObject.ToString(). Ie: > > string JsonString = JObject.ToString(); > > When the string is generated the new lines are just passed straight through > without being escaped, causing the receiving end to generate an error. > > Does anybody know why this is happening? > > Thanks in advance > Terry. > > > > > > -- > View this message in context: > http://mono-for-android.1047100.n5.nabble.com/JsonObject-ToString-not-escaping-new-lines-tp5710632.html > Sent from the Mono for Android mailing list archive at Nabble.com. > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid >
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid