Base64 Decode in php with a json_decode -


hi have following issue in instances json_decode not work , empty array follows.

// test purpose set inbound enc parameter $_post["enc"] = "eyj0cmfuc2nyaxb0ijoilsagicagicagicbqyxn0zwqgdghlihrlehqgaw50bybob3rlcgfkibmgbm8gc3bly2lhbcbjagfyywn0zxjziiwiawqiojcwlcjpc0fjdglvbmvkijp0cnvllcj1c2vyx2lkijoxlcj0yxnrx3r5cgvfawqiojesimfjy291bnrfawqiojixlcjhy2nvdw50x25hbwuioijurvnuiiwizxzlbnrfzgf0zsi6bnvsbh0=";  $decoded = base64_decode($_post["enc"]); $ar = (array)json_decode($decoded);  echo "<pre>";     print_r($decoded); echo "</pre>";  echo "<pre>";     print_r($ar); echo "</pre>"; 

$decoded displays json string, $ar null.

any please appreciated in helping me issue.

taking code , decoding base64 encoded string turns out have chr(13) ascii character in json data causing json fail validation according json lint. taking character out results in json parsing correctly.

php fiddle

decoded json data:

{     "transcript": "-          pasted text notepad  no special characters",     "id": 70,     "isactioned": true,     "user_id": 1,     "task_type_id": 1,     "account_id": 21,     "account_name": "test",     "event_date": null } 

hex editor screenshot:
hex editor screenshot


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

python - Scapy Dot11ReassoReq -