In your second scenario, since you have changed "tags" to "tag", are you parsing the JSON as below - note the missing 's' in reponse.tag?
var tags = $.parseJSON(response.tag);
Вопрос
I have a problem on both parsing legal and validated JSON objects.
This one runs okay
var response = {"tags":"[{\"value\": 2,\"label\": \"Dubstep\"},{\"value\": 3,\"label\": \"BoysIIMen\"},{\"value\": 4,\"label\":\"Sylenth1\"}]"};
var tags = $.parseJSON(response.tags);
console.log(tags);
It Prints Out on the Console Array[3]
but when I run I change the value of var response
to this one
var response = {"tag":"[{\"id\":2,\"name\":\"Dubstep\",\"description\":\"Dub wob wob\"},{\"id\":3,\"name\":\"BoysIIMen\",\"description\":\"A 1990s Boy Band\"},{\"id\":4,\"name\":\"Sylenth1\",\"description\":\"A VST Plugin for FLStudio \"}]"};
the value of tags
is null
take note that both values are validated on JSONLint.
Нет правильного решения
Другие советы
In your second scenario, since you have changed "tags" to "tag", are you parsing the JSON as below - note the missing 's' in reponse.tag?
var tags = $.parseJSON(response.tag);
Your second example starts:
{"tag":
This should be
{"tags":