I want to add JSON data with the following string value:
json = "d:\xyz\abc";
This value is coming from a database at runtime. When I am going to display it in datatable, JSON formatting error is displayed. My requirement is that the above value will be displayed as it is in the datatable. Please help.
You’d better use a JSON library for your programming language. You don’t retrieve database values directly with jquery, aren’t you?
So, you’d use something like
JSON.escape(my_string_from_db), or, in Ruby language I usually domy_string.to_json.This will automatically escape everything that needs to be escaped.