什么是使用JSON数组VS JSON对象之间的差异? [英] What are the differences between using JSON arrays vs JSON objects?

查看:237
本文介绍了什么是使用JSON数组VS JSON对象之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用JSON阵列的区别和优势:

  {
   事情:[
     {},
     {}
   ]
}

与JSON对象:

  {
   事情:{
     {},
     {}
   }
}


解决方案

不是听起来像一个聪明的驴子,但远...

阵列对象的区别

对象都设置使用像...

  person.age = 15;

如果在值是一个变量,那么可以访问它像...

  VAR键=年龄;
警报(人[关键]);

阵列,可以使用一个整数[1]指标,并采取一个值。

 播放器[1] .score + = 1000;

[1]是的,我知道... JavaScript中的整数索引真的变成了幕后的字符串。忽略。想取一个整数数组尤其是当你觉得JSON的。

What are the difference and advantages of using JSON arrays:

{
   thing:[
     { },
     { }
   ]
}

versus JSON objects:

{
   thing:{
     { },
     { }
   }
}

解决方案

Not to sound like a smart ass, but well...

The difference between an array and an object.

Objects are set up using a key and value like...

person.age = 15;

If the key value is a variable, then one could access it like...

var key = "age";
alert(person[key]);

Arrays use an integer[1] index and take a value.

player[1].score += 1000;

[1] Yes, I know ... in Javascript the integer index is really turned into a string behind the scenes. Ignore that. Think of arrays taking an integer value ESPECIALLY when you think of JSON.

这篇关于什么是使用JSON数组VS JSON对象之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆