I have an array as follows contained in $config:
Array
(
[1] => Array
(
[outlet] => facebook
[thumbnail] => /images/catalog/modules/videoplayer/Original.jpg
[url] => http://www.google.com
[copy] => this is a test
[vidurl] => http://www.youtube.com
[poster] => none
)
[2] => Array
(
[outlet] => facebook
[thumbnail] => /images/catalog/modules/videoplayer/limon2.jpg
[url] => http://www.yahoo.com
[copy] => Here is the copy
[vidurl] => http://www.vimeo
[poster] => no poster
)
)
I'm converting it into JSON as follows:
$module->configuration = json_encode($config,JSON_PRETTY_PRINT);
Everything saves to the DB fine, producing this object upon retrieval:
App\Module Object
(
[table:protected] => modules
[timestamps] =>
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[attributes:protected] => Array
(
[id] => 3
[title] => wddwdw
[type] => socialfeed
[configuration] => {
"1": {
"outlet": "facebook",
"thumbnail": "\/images\/catalog\/admin\/no_image.png",
"url": "wdwd",
"copy": "wd",
"vidurl": "wdw",
"poster": "wd"
},
"2": {
"outlet": "facebook",
)
[original:protected] => Array
(
[id] => 3
[title] => wddwdw
[type] => socialfeed
[configuration] => {
"1": {
"outlet": "facebook",
"thumbnail": "\/images\/catalog\/admin\/no_image.png",
"url": "wdwd",
"copy": "wd",
"vidurl": "wdw",
"poster": "wd"
},
"2": {
"outlet": "facebook",
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[morphClass:protected] =>
[exists] => 1
)
As you can see the json is broken. When I retrieve $model->configuration it is broken:
{
"1": {
"outlet": "facebook",
"thumbnail": "\/images\/catalog\/admin\/no_image.png",
"url": "wdwd",
"copy": "wd",
"vidurl": "wdw",
"poster": "wd"
},
"2": {
"outlet": "facebook",
Is there something else I need to do before writing the json to the DB to make sure it is retrievable?