For example, if you got the following PHP array
$imagesToBeShown = array('1.jpg', '2.jpg', '3.jpg');
will give you a string containing
$jsonString = json_encode($imagesToBeShown);
var jsonString, you just use
var imagesToBeShown = eval('(' + jsonString + ')');
(Of course you should only use the eval notation when the source is trusted, which is the case here.)
As for the manually updating the hexcode database, how exactly are you planning on converting a carpet into a single hexcode (or several, for that matter)?