I previously asked a question here on SO about this issue, but now I observed that I did not investigate much about the issue, thus I wrongly concluded that the error was in the JSON library I was using (Newtonsoft), as specified in that previous question.
After testing with Microsoft's Web.Script.Serialization and exactly the same issue persists, I thus deem it fit to rather ask it as a separate SO question; so that the question will attract the appropriate audience, with the appropriate title.
Aside from the above clarification, the issue still remains the same, with more details below:
In my c# application. I have the following c# class to serialize:
class resultCommentsJsonMask
{
public List<resultCommentAuthorityEntry> authorities { get; set; }
public resultCommentTypes globalComments { get; set; }
public List<string> commentTypes { get; set; }
}
public class resultCommentAuthorityEntry
{
public string name { get; set; }
public string description { get; set; }
public string commentType { get; set; }
public bool useGlobalSelectableComments { get; set; }
public bool useGlobalAutomatedComments { get; set; }
public resultCommentTypes comments { get; set; }
}
public class resultCommentTypes
{
public string selectable { get; set; }
public List<resultCommentBoundary> automated { get; set; }
}
public class resultCommentBoundary
{
public decimal lowerRange { get; set; }
public decimal upperRange { get; set; }
public string comment { get; set; }
}
After creating an instance of resultCommentsJsonMask
and filling it with data, I did JsonConvert.SerializeObject(instance_of_resultCommentsJsonMask)
However, on 2 other computers (my app users), all JSON keys were replaced with strange characters.
The only obvious differences between those computers and mine is that I am using a 32 bit Windows 7 PC while theirs is 64 bit Windows 10. Even more confusing now is the fact that I got another Windows 10 PC where everything works perfectly exactly like my own Win 7 computer.
I converted the app to a console app and logged the serialized JSON output on my PC to console, and I got the following, correct, JSON output:
However, the console output on those other (Windows 10) PCs had garbled text in form of question marks where JSON keys are meant to be (like "Authorities", "Name", etc. in my console output above), as shown below:
Also note that this issue persists even when I used Microsoft's Javascriptserializer JSON library instead of Newtonsoft, making me to want to conclude that it is a "library-agnostic" issue.
Edit
The relevant code used to generate the console output above:
var json = serializer.Serialize(commentsStore);
Console.WriteLine(string.Format("Setting store: {0}", json));