是否保留了 JSON 列表中元素的顺序? [英] Is the order of elements in a JSON list preserved?

查看:29
本文介绍了是否保留了 JSON 列表中元素的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 JSON 对象中元素的顺序不是原始顺序.

I've noticed the order of elements in a JSON object not being the original order.

JSON 列表的元素呢?他们的订单是否维护?

What about the elements of JSON lists? Is their order maintained?

推荐答案

是的,JSON 数组中元素的顺序是保留的.来自 RFC 7159 - JavaScript 对象表示法 (JSON) 数据交换格式(强调我的):

Yes, the order of elements in JSON arrays is preserved. From RFC 7159 -The JavaScript Object Notation (JSON) Data Interchange Format (emphasis mine):

对象是零个或多个名称/值的无序集合对,其中名称是字符串,值是字符串、数字、布尔值、空值、对象或数组.

An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array.

数组是零个或多个值的有序序列.

An array is an ordered sequence of zero or more values.

术语对象"和阵列"来自的约定JavaScript.

The terms "object" and "array" come from the conventions of JavaScript.

某些实现也确实保留了 JSON 对象的顺序,但这并不能保证.

Some implementations do also preserve the order of JSON objects as well, but this is not guaranteed.

这篇关于是否保留了 JSON 列表中元素的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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