为什么parseJSON返回null

I-M*_*-JM 8 jquery json

我有以下jQuery/JS代码

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
  $.getJSON("http://example/topics", {}, function(data){
           console.log( data ); // display the JSON *data* in the web console
           console.log( $.parseJSON(data) );
  });
</script>
Run Code Online (Sandbox Code Playgroud)

console.log(data)显示firebug控制台(firefox附加组件)中的JSON数据,但console.log($ .parseJSON(data))显示为null.

可能的原因是什么.

我需要将JSON字符串转换为数组.

Fel*_*ing 21

我假设因为$.getJSON已经解析了数据.data是Javascript对象.

success回调被传递返回的数据,其通常是JavaScript对象或阵列由JSON结构所定义和使用所解析的$.parseJSON()方法.

当然,如果你向我们展示输出,我们可以说更多,但通常,$.getJSON已经解析了响应.

PS:我希望你在真实的代码中使用正确的URL.