I have json record which was build manually below which work fine with my application

```
<?php 

$arr= '{
"items": [{
        "title": "my first title",
        "id": "101",
        "address": {
            "label": "my first label",
            "countryCode": "FRA"
        },
        "position": {
            "lat": 37.37634,
            "lng": -122.03405
        }
    },

    {
        "title": "my second title",
        "id": "102",
        "address": {
            "label": "my second label",
            "countryCode": "USA"
        },
        "position": {
            "lat": 37.37634,
            "lng": -122.03405
        }
    }
]
}';

echo $arr;    
?>

```

**Here is my issue:** I have a database with records below which I want to covert to Json as per format above. my main issue is how to implement the **address{}** and **position{}** parameters in the json records.

Here is my efforts so far

```
include('pdo.php');

$res1 = $db->prepare("SELECT * FROM data");
$res1->execute(array());

while($row = $res1->fetch()){

    $id = htmlentities(htmlentities($row['id'], ENT_QUOTES, "UTF-8"));
    $label = htmlentities(htmlentities($row['label'], ENT_QUOTES, "UTF-8"));
    $title = htmlentities(htmlentities($row['title'], ENT_QUOTES, "UTF-8"));
    $countryCode = htmlentities(htmlentities($row['countryCode'], ENT_QUOTES, "UTF-8"));
    $lat = htmlentities(htmlentities($row['lat'], ENT_QUOTES, "UTF-8"));
    $lng = htmlentities(htmlentities($row['lng'], ENT_QUOTES, "UTF-8"));

    $arr[] = array(
            "id" => $id,
            "label" => $label,
            "title" => $title,
            "countryCode" => $countryCode,
            "lat" => $lat,
            "lng" => $lng
        );
}

echo json_encode($arr);

```