This doesn’t really have much to do with JSON, rather with string concatenation.
The txt variable is a string and begins with a single quote, so that the double quotes that occur within it don’t have to be escaped.
If you wrote it using double quotes, you would have to write:
var txt = "{ \\"employees\\" : [" +
and so on …
Q2.why in the value " + txt + " is present? is this showing blank space then txt and then again space?[/QUOTE]
We have already established that txt is a string and again, this is an example of string concatenation. eval is passed a string as an argument, in this case a string consisting of a bracket, the variable txt and a closing bracket.
If it makes it any easier to understand, you could rewrite your example as:
We have already established that txt is a string and again, this is an example of string concatenation. eval is passed a string as an argument, in this case a string consisting of a bracket, the variable txt and a closing bracket.
If it makes it any easier to understand, you could rewrite your example as: