Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NewtonSoft JSON serializer and UTF8 support [closed]

Tags:

json

c#

json.net

I have a simple method using NewtonSoft's JSON serializer and I love it (simple, returns formatted JSON). However I can't seem to get it to properly serialize UTF8 characters (they show up as a question mark i.e. '?') that are found in strings within an object.

The code I'm using is:

string serialized = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { });
like image 232
joelc Avatar asked Oct 27 '12 21:10

joelc


1 Answers

Since you're serializing to a string and not to a byte array, you're not dealing with any character encodings (like utf-8) at this stage.

You'll have to find out where it's actually converted to/from UTF-8 and fix the problem there.

like image 92
johv Avatar answered Sep 19 '22 03:09

johv