I'm writing to the db (I'm automatically creating a module):
$module = new stdClass();
$module->title = $moduleTitle;
$module->note = "";
$module->content = "";
$module->position = $modulePosition;
$module->checked_out = 0;
$module->publish_up = "";//current data and time in Y-M-day time e.g.2020-05-26 08:53:56
$module->publish_down = "0000-00-00 00:00:00";
$module->published = 1;
$module->module = $moduleModule;
$module->access = $moduleAccess;
$module->showtitle = 1;
$module->params = $moduleParams;
$module->client_id = 0; //front end module
$module->language = "*";
JFactory::getDbo()->insertObject('#__modules', $module, 'primary_key');
This all works great apart from the $module params. I create them by
$myParams->available_page_groups = '["'.$currentmenuid.'"]';
$myParams->show_page_title = 0;
$myParams->show_page_notes = 0;
$myParams->show_page_owner = 0;
etc.
$myJSON = json_encode($myParams);
Which produces correctly encoded JSON. However when I look in the database the params have been escaped:
{"available_page_groups":"[\"13\"]","show_page_title":0,"show_page_notes":0,...
they should read
{"available_page_groups":"["13"]","show_page_title":0,"show_page_notes":0,...
Can someone tell me how to stop the insertObject adding in the escape characters or is there another way I need to do this - i.e. some sort of raw filter to apply?
thanks