문제

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":
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top