- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我已经仔细阅读了 JSON 描述 http://json.org/但我不确定我是否知道这个简单问题的答案。什么字符串是最小可能的有效 JSON?
"string"
字符串是合法的 JSON 吗?42
是简单数字有效的 JSON 吗?true
bool 值是有效的 JSON 吗?{}
空对象是有效的 JSON 吗?[]
空数组是有效的 JSON 吗?最佳答案
在撰写本文时,JSON 仅在 RFC4627 中进行了描述。 .它将 JSON 文本描述为(在“2”的开头)作为序列化对象或数组。
这意味着 只有 {}
和 []
在符合该标准的解析器和字符串化器中是有效的、完整的 JSON 字符串。
然而,ECMA-404 的引入改变了这一点,更新的建议 can be read here .我也有written a blog post关于这个问题。
为了进一步混淆这个问题,JSON
对象(例如 JSON.parse()
和 JSON.stringify()
)在网络浏览器是 standardised in ES5 ,并且清楚地定义了可接受的 JSON 文本,如下所示:
The JSON interchange format used in this specification is exactly that described by RFC 4627 with two exceptions:
The top level JSONText production of the ECMAScript JSON grammar may consist of any JSONValue rather than being restricted to being a JSONObject or a JSONArray as specified by RFC 4627.
snipped
这意味着 JSON 对象接受 所有 JSON 值(包括字符串、空值和数字),即使 JSON 对象在技术上遵循 RFC 4627。
请注意,您可以因此在符合标准的浏览器中通过 JSON.stringify(5)
对数字进行字符串化,这将被另一个遵循 RFC4627 但没有具体规定的解析器拒绝上面列出的异常(exception)。 Ruby,例如 would seem to be one such example which only accepts objects and arrays as the root .另一方面,PHP specifically adds the exception即“它还将对标量类型和 NULL 进行编码和解码”。
关于javascript - 最低有效 JSON 是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18419428/
This question already has answers here: Closed 11 years ago. Duplicate: Recommended website resoluti
我有一个网络应用程序需要 IE9。其他浏览器(Firefox、Chrome、Opera 等)的等效浏览器版本是什么? 我知道如何检查用户当前的浏览器/版本,如果不支持,我需要看看是否可以为用户提供下载
我在比较 Mysql 数据库中的两个值并显示最低值时遇到问题。 比如我有这个: value1 = 23.4 value2 = 4.479 我试过这个: ORDER BY CAST(column AS
我有一个需要使用的功能,但我需要将我的最小 SDK 设置为 23 才能使用它。问题是,我们的应用程序运行在很多低端 SDK 设备上。有什么方法可以设置我的项目以允许我在编译应用程序的同时仍然使用较低的
我需要在32位数字中获得一个1位数字,其中只有一个1位(总是)。用C ++或asm最快的方法。 例如 input: 0x00000001, 0x10000000 output:
我已经对我的数据进行了分组。现在,我要做的是每周从“高”列中选择最高值,并从“低”列中选择最低值,然后使用最高值减去最低值得到范围。但是代码总是错误的。有人对我有想法吗? 这是我的 DataFrame
如何编写一个存储 20 个数字的数组,然后显示以下数据:数组中最小的数字、最大的数字、数字的总和以及它们的平均值? 最佳答案 使用java编程语言 int myArray[] = {15,25,85,
在学习 C 的同时做一些实验,我遇到了一些奇怪的事情。这是我的程序: int main(void) {sleep(5);} 当它被编译时,可执行文件的文件大小为 8496 字节(与 26 字节的源代码
我已经创建了我想在我的项目中使用的包。在包中,我使用的是 UIStackView。当我将包添加到项目并运行它时,我收到错误 'UIStackView' 仅适用于 iOS 9.0 或更高版本。如果我的项
我已经制定了一个程序来显示给定日期的特定时间的最高和最低流行项目。该过程没有错误或异常,并且一切正常。如您所见,为了显示 Items 的第一条记录,查询重复了两次,但唯一的区别在于顺序(ASC 和 D
我是 BPEL/BPMN 新手。 是否可以在没有 WS-* Web 服务和 EJB 容器(例如 jBoss、WebLogic、Glassfish)的情况下编写 BPEL/BPMN 感知软件? 我想知道
我们正在使用 OpenGL 4.3。但是,我们担心我们使用的功能适用于我们的显卡,但不符合 OpenGL 4.3 的“最低”要求规范。 是否有可能模拟最低限度的行为?例如,让显卡拒绝任何非标准纹理格式
我正在我的应用程序中实现 Facebook SDK。 按照 facebook 开发人员指南,除了我没有设置 GIT,所以我下载了 SDK,并将其导入 Eclipse,将 Java 合规级别更改为 1.
所以我构建了一个使用 API 15 中特定默认配色方案的应用程序。但是,我知道大多数设备仍在运行 API 10。为了吸引这些设备,我在我的设备上切换了最小 SDK设备到 10。这样做之后,我注意到我的
数据 所以,假设我有一个应用程序,我正在测试汽车的速度、性能、安全性等。我有一组以下格式的数据: CAR TABLE ID CAR_NAME 1 Ford Focus 2006 2 To
我有以下查询: SELECT AVG(q1) AS q1, AVG (q2) AS q2, AVG(q3) AS q3, AVG(q4) AS q4, AVG(q5) AS q5 FROM tresu
我刚刚创建了我的第一个 Android 应用程序(第 10 次)。我创建的项目的 sdk 比我预期的要高,现在我想降低它。我最初的 android maifest 不包含 部分,所以我补充说: 我还
我的小组作业是制作一个程序,允许用户输入任意数量的数字,然后程序会告诉你输入的最高数字、输入的最低数字、平均值、输入的总数和平均值。我们必须使用菜单。 我们已经写好了菜单。我们的大部分计算代码都在案例
我正在尝试设置一个显示文档目录中数据的 UITableView。 我对代码有点迷茫,因为我尝试了来自 Google 和论坛等的许多示例。 我正在创建没有 Storyboard 的应用程序,所以它全部在
我们都知道将最后 1 位设置为 0 的技巧 n&(n-1)。例如,0110 & (0110-1) = 0100。但是反过来呢?将最后一个 0 设置为 1?所以 0110 变成 0111? 我在 sta
我是一名优秀的程序员,十分优秀!