javascript – 什么是任意数据/ JSON?

前端之家收集整理的这篇文章主要介绍了javascript – 什么是任意数据/ JSON?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近遇到了任意数据/任意json一词,我似乎无法理解究竟是什么和/或找到任何文件.我知道 JSON是一种通过互联网发送数据的格式,那么格式究竟是如何随意的呢?

编辑::

//更多代码

  1. var buildItem = function(item) {
  2. var title = item.name,args = [],output = '<li>';
  3.  
  4. if (item.type == 'method' || !item.type) {
  5. if (item.signatures[0].params) {
  6. $.each(item.signatures[0].params,function(index,val) {
  7. args.push(val.name);
  8. });
  9. }
  10. title = (/^jQuery|deferred/).test(title) ? title : '.' + title;
  11. title += '(' + args.join(',') + ')';
  12. } else if (item.type == 'selector') {
  13. title += ' selector';
  14. }
  15. output += '<h3><a href="' + item.url + '">' + title + '</a></h3>';
  16. output += '<div>' + item.desc + '</div>';
  17. output += '</li>';
  18.  
  19. return output;
  20. };
  21.  
  22. //more code

在上面的示例代码中,我被告知.params是来自JSON请求的任意数据[用于jQuery API文档].

什么是任意数据?

非常感谢任何答案和/或澄清.

jsFiddle:http://jsfiddle.net/QPR4Z/2/

谢谢!

解决方法

arbitrary |ˈärbiˌtrerē|
adjective

based on random choice or personal whim,rather than any reason or
system: his mealtimes were entirely arbitrary.

  • Mathematics: (of a constant or other quantity) of unspecified value.

这只意味着那里可能有任何价值.这与一个说“像这个数组总是包含X,Y和Z”的规范相反.相反的任意值说“我们在这个阵列中发送了一些东西,但我们不能事先告诉你究竟是什么.”如果你被告知你可以自己发送任意数据,这意味着你可以发送任何你想要的东西,它不必遵循任何特定的格式.

请注意,这完全是关于JSON格式中包含的数据,而不是JSON格式本身.

猜你在找的JavaScript相关文章