This is all you need for valid JSON, right?

["somestring1", "somestring2"]

推荐答案

I'll elaborate a bit more on ChrisR awesome answer and bring images from his awesome reference.

一个有效的JSON总是以大括号{或方括号[开头,而不是别的.

{ will start an object:

left brace followed by a key string (a name that can't be repeated, in quotes), colon and a value (valid types shown below), followed by an optional comma to add more pairs of string and value at will and finished with a right brace

{ "key": value, "another key": value }

Hint:虽然javascript接受单引号',但JSON只接受双引号".

[ will start an array:

left bracket followed by value, optional comma to add more value at will and finished with a right bracket

[value, value]

Hint: spaces among elements are always ignored by any JSON parser.

And value is an object, array, string, number, bool or null:

Image showing the 6 types a JSON value can be: string, number, JSON object, Array/list, boolean, and null

So yeah, ["a", "b"] is a perfectly valid JSON, like you could try on the link Manish pointed.

下面是几个额外的有效JSON示例,每个块一个:

{}

[0]

{"__comment": "json doesn't accept comments and you should not be commenting even in this way", "avoid!": "also, never add more than one key per line, like this"}

[{   "why":null} ]

{
  "not true": [0, false],
  "true": true,
  "not null": [0, 1, false, true, {
    "obj": null
  }, "a string"]
}

Json相关问答推荐

MariaDB杨森:在任何子属性中包含特定值

嵌套自定义解组

无法根据vega规范中的条件设置文本 colored颜色

当有嵌套数组而没有嵌套数组时,展平JSON

JSON字符串处理注入引号

kotlinx-serialization:如何将具有不同类型对象的JsonArray转换为同一个Class

如何在PowerShell中扩展JSON中的嵌套数组

与错误相关的未定义&Quot;不是有效的JSON

将 JSON 字符串解析为 Kotlin Android 中的对象列表(MOSHI?)

如何从字符串中创建一个逗号分隔的列表,由 API 中的 JSON 对象内的编号空格分隔?

使用 KQL 和外部 data() 运算符从 json 文件中提取信息

Powershell中等效的JSONPath通配符以 Select 对象中的所有数组

Laravel5 Json 获取文件内容

将文件发送到 Rails JSON API

在 Android 中使用带有 post 参数的 HttpClient 和 HttpPost

Retrofit2.0 得到 MalformedJsonException 而 json 似乎正确?

JSON 模式 - 如果对象*不*包含特定属性则有效

Protocol Buffer vs Json - 何时 Select 一个而不是另一个

如何从 MySQL 中检索 JSON 数据?

在 iPhone 上解析 JSON 日期