Frankly, it would be infinitely better to be able to write:
$data = {
firstName: "John",
lastName: "Smith",
age: 25,
address: {
streetAddress: "21 2nd Street",
city: "New York",
state: "NY",
postalCode: 10021
},
phoneNumber: {
home: {
number: "212 555-1234"
},
fax: {
number: "646 555-4567"
}
}
};
Rather than the awkward and verbose: $data = (object) [
"firstName" => "John",
"lastName" => "Smith",
"age" => 25,
"address" => (object) [
"streetAddress" => "21 2nd Street",
"city" => "New York",
"state" => "NY",
"postalCode" => 10021
],
"phoneNumber": (object) [
"home" => (object) [
"number" => "212 555-1234"
],
"fax" => (object) [
"number" => "646 555-4567"
]
]
];
JSON is everywhere these days, supporting object literals is a very, very big deal; I understand which features to implement are handpicked very carefully so as not to clutter more the core, but we are talking about making the life of devs who use and write JSON more difficult, and that happens to be lots of folks.Telling people to use arrays and be done with it is the equivalent of implement a strpos function that may only accept a string that's 5 characters long — yes, theoretically you can work with that splitting your strings, but that's time consuming and a inconsistent behaviour (why would 10 character long strings be less of a citizen than 5 char long ones?)