tomdchi Posted June 5, 2013 Share Posted June 5, 2013 (edited) Is WHMCS doing something to php's json_decode function? I have a custom client page where a json string is being posted from a form. I can echo out the post var before I call json_decode and it shows OK. After decode I print_r the output nothing is returned. Very strange. Also, encoding is set to utf-8. When I echo the json post var it outputs OK: <?php define("CLIENTAREA", true); define("FORCESSL",true); require("init.php"); $ca = new WHMCS_ClientArea(); $ca->setPageTitle("SureTax JSON Validator"); $ca->addToBreadCrumb('index.php', $whmcs->get_lang('globalsystemname')); $ca->addToBreadCrumb('json_validator.php', 'SureTax JSON Validator'); $ca->initPage(); if (isset($_POST['json'])) { $json = $_POST['json']; echo $json; exit; $decoded = json_decode($json, true); print_r($decoded); $ca->assign('validate', validate_json($json)); } Output: {"ClientNumber":"000000002","BusinessUnit":"RPS","DataYear":"2013","DataMonth":"04","TotalRevenue":"32.00"} Now when I try to run it through json_decode and print_r it outputs nothing. if (isset($_POST['json'])) { $json = $_POST['json']; $decoded = json_decode($json, true); print_r($decoded); exit; $ca->assign('validate', validate_json($json)); } Just to make sure that the json_decode function works I coded in the json string and the output was as expected. if (isset($_POST['json'])) { $json = '{"ClientNumber":"000000002","BusinessUnit":"RPS","DataYear":"2013","DataMonth":"04","TotalRevenue":"32.00"}'; $decoded = json_decode($json, true); print_r($decoded); exit; $ca->assign('validate', validate_json($json)); } Output: Array ( [ClientNumber] => 000000002 [businessUnit] => RPS [DataYear] => 2013 [DataMonth] => 04 [TotalRevenue] => 32.00 ) Anyone have any idea why it is doing this? Edited June 5, 2013 by tomdchi 0 Quote Link to comment Share on other sites More sharing options...
tomdchi Posted June 6, 2013 Author Share Posted June 6, 2013 solved, apparently WHMCS runs post vars through html_encode. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.