I have a database with next scheme, that uses postgressql and the postgis plugin: 

```none
table_id | id | mag | time | felt | tsunami | geom

```

I have a next SQL to select some rows and return those columns as a JSON: 

```sql
SELECT ROW_TO_JSON(t) as properties 
FROM ( 
  SELECT id, mag, time, felt, tsunami FROM earthquakes
) t

```

I would like to create an SQL sentence that returns the table\_id, properties and geom like: 

```
SELECT table_id, properties, GeometryType(geom) 
from earthquakes

```

How can I return the table\_id and geom with properties as a JSON?

Edit: 

I've created this sql:

```
SELECT table_id, 
row_to_json((SELECT d FROM (SELECT id, mag, time, felt, tsunami ) d)) AS properties, 
GeometryType(geom) 
FROM earthquakes ORDER BY table_id ASC;

```

But when I do a request with postman, it returns this:

```
[
    {
        "table_id": 1,
        "properties": {
            "type": "json",
            "value": "{\"id\" : \"ak16994521\", \"mag\" : 2.3}"
        }
    },
    ...
]

```

How can I return the values as an object?

My expected result should be:

```
[
    {
        "table_id": 1,
        "properties": {"id" : "ak16994521", "mag" : 2.3}
    },
    ...
]

```

Java Method:

```
public List<Map<String, Object>> readTable(String nameTable) {
    try {
        String SQL = "SELECT table_id, GeometryType(geom) FROM " + nameTable + " ORDER BY table_id ASC;";           
        return jdbcTemplate.queryForList(SQL);
    } catch( BadSqlGrammarException error) {
        log.info("ERROR READING TABLE: " + nameTable);
        return null;
    }
}

```

whit this code returns this json:

```
 [
    {
        "table_id": 1,
        "geometrytype": "POINT"
    },
    {
        "table_id": 2,
        "geometrytype": "POINT"
    },
    ....
]

```

My expected result should be:

```
[
    {
        "table_id": 1,
        "properties": {"id" : "ak16994521", "mag" : 2.3, "time": 1507425650893, "felt": "null", "tsunami": 0 },
        "geometrytype": "POINT"
    },
    ...
]

```