Question: I have several tables that have JSON arrays stored within fields.

Using PHP PDO I am able to retrieve this data without issue using:

```
$query1 = $database->prepare("SELECT * FROM module_settings
                WHERE project_token = ? AND module_id = ? ORDER BY id DESC LIMIT 1");  
$query1->execute(array($page["project_token"], 2));
$idx = $query1->fetch(PDO::FETCH_ASSOC);
$idx["settings"] = json_decode($idx["settings"]);

```

This returns a string like:
{"mid":"","module\_id":"1","force\_reg\_enable":"1","force\_reg\_page\_delay":"2"}

Attempting to gather the same data via PhalconPHP

```
$result = Modulesettings::findFirst( array( 
    'conditions' => 'project_token = "' . $token . '"' , 
    'columns' => 'settings' 
) );

var_dump($result);

```

Provides a result of

```
object(Phalcon\Mvc\Model\Row)#61 (1) { ["settings"]=> string(167) "{"text":"<\/a>

<\/a>
","class":""}" }

```

What do I need to do different in Phalcon to return the string as it is stored in the table?

Thank you.

Answer: 
You have 2 approach  

First :  

Get the settings with this structure : 

```
$settings = $result->settings;
var_dump($settings);

```

Second :  

First get array from `resultset`, then using the array element : 

```
$res = $result->toArray();
var_dump($res['settings']);

```

Try it.
You can decode json right in your `Modulesettings` model declaration:

```
// handling result
function afterFetch() {
    $this->settings = json_decode($this->settings);
}

// saving. Can use beforeCreate+beforeSave+beforeUpdate
// or write a Json filter.
function beforeValidation() {
    $this->settings = json_encode($this->settings);
}

```