Does JSON syntax allow duplicate values?

Is this valid JSON?

{
    "a" : [
      "x",
      "x"
    ]
}

http://jsonlint.com/ says yes.

http://www.json.org/ doesn't say anything about it being forbidden, but does say:

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

  • "An ordered list of values" suggests duplicates are therefore valid. Is this correct? Is there anything more explicit? Are there any JSON implementation which don't allow duplicate values?

    (Here's the related question about duplicate keys.)


    That is valid JSON. What is not allowed is having duplicate keys, such as:

    {
        "a": 1,
        "a": 2
    }
    

    Also, by "ordered" I believe it refers to the fact that values have a predefined, well established order, not that they are sorted in any way :)

    链接地址: http://www.djcxy.com/p/6460.html

    上一篇: PowerShell ParameterBindingException

    下一篇: JSON语法是否允许重复值?