I'm building a JSON with PHP, and the keys can't be quoted, because I need to import it into Neo4j.
I'm using this to build it in PHP, inside a loop:
$contacts[$contact_key]["addr"][$addr_key]["zipcode"] = $zip_match[0];
$contacts[$contact_key]["addr"][$addr_key]["housenumber"] = $house_match[0];
And eventualy I use:
$reencoded = json_encode($contacts, JSON_UNESCAPED_UNICODE);
$reencoded = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', $reencoded);
So this is a part of the JSON string result:
{addr:{1:{zipcode:"1315 GN",housenumber:"1229P;"}}
But I can't have numbered keys like 1:, 2: ect.
because that gives me a error in Neo4j.
I preferly need to achieve this format:
{addr: [{zipcode:"1315 GN",housenumber:"1229P"}]
How can I make a list of adresses for a contact person, without having numbered keys?
$contact_keyat 0 and increment it then the numbers will be absent in the JSON. But the non-quoted keys is NOT valid JSON so what is Neo4j doing?