JSON and MySQL related functions carved off from the monolithic functions.php