Answer the question
In order to leave comments, you need to log in
When I try to make an object from a JSon object, it writes an error of an unknown character &, how to fix it?
I'm trying to convert Object to json chrome writes an error:
Uncaught SyntaxError: Unexpected token &
Code:
var tr = @Newtonsoft.Json.JsonConvert.SerializeObject(traingObj);
start(@tr);
Answer the question
In order to leave comments, you need to log in
Hey! Perhaps the option is suitable when we serialize html characters into an escape sequence:
var settings = new JsonSerializerSettings
{
StringEscapeHandling = StringEscapeHandling.EscapeHtml
};
var tr = @Newtonsoft.Json.JsonConvert.SerializeObject(traingObj, settings);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question