Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a JSON name-value pair have an empty name?

Tags:

json

I am testing my JSON code with sample.json from the test suite here and it contains a lot of name-value pairs where the name is just an empty string, i.e. "". Is this correct? RFC4627 just states that the name SHOULD be unique but does not mention empty names.

like image 431
Jannie Gerber Avatar asked Oct 27 '25 08:10

Jannie Gerber


1 Answers

The specification defines objects as such:

object
    {}
    { members }

members
    pair
    pair , members

pair
    string : value
    array

string
    ""
    " chars "

In other words, an object may be empty or contain members. members are pairs. A pair is a string : value. A string is "" or " chars ".

That means empty strings are valid strings which are valid in a pair which is a valid member which is valid in objects.

like image 110
deceze Avatar answered Oct 29 '25 22:10

deceze