I have a PHP variable I need to convert to JSON string.
I have following PHP code:
$username="admin";
$password="p4ssword";
$name="Administrator";
$email="[email protected]" 
$params=compact('username', 'password','name','email', 'groups');
json_encode($params);
This works fine. But what I am not sure about is how do I encode the properties in PHP with nested key value pairs shown below:
{
"username": "admin",
"password": "p4ssword",
"name": "Administrator",
"email": "[email protected]",
"properties": {
    "property": [
        {
            "@key": "console.rows_per_page",
            "@value": "user-summary=8"
        },
        {
            "@key": "console.order",
            "@value": "session-summary=1"
        }
    ]
   }
}
What is this with @ before key value?
json_encodewill encode any variable to JSON, regardless of how nested it is.