note 115293 added to function.json-decode

From: Date: Tue, 01 Jul 2014 02:44:40 +0000
Subject: note 115293 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-199785@lists.php.net to get a copy of this message
Hi All, I encountered the same issue with json_decode() from valid JSON file. I try differents solutions suggested by users but nothing works for me whereas this strange solution. So i add this note for users who wants to try my solution. I put my file in ANSI encoding with these few following lines codes. -------------{ File : myJsonFile.json [encoding : ANSI] }-------------- ----------------------------------------------------------------------- { "Property1" : "value1", "Property2" : "value2" } ----------------------------------------------------------------------- ----------------------------------------------------------------------- AND -----{File : myPHPFileWhichNeedJSON.php [encoding : ANSI] }---- --------------------------------------------------------------- $fileContent = file_get_contents('myJsonFile.json'); $obj = json_decode($fileContent, true); print_r($obj); --------------------------------------------------------------- --------------------------------------------------------------- Print_r return : -------------------- Array ( [Property1] => value1 [Property2] => value2 ) Notes : ---------- - First I try to change PHP File encoding -> No change - I try to put my JSON File in UTF-8 -> Nothing -> I use Notepad++ to define file encoding Informations : ------------------- - phpversion() -> 5.3.28 Neoblaster. ---- Server IP: 216.194.115.244 Probable Submitter: 109.190.59.171 ---- Manual Page -- http://php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/115293 Del: integrated -- https://master.php.net/note/delete/115293/integrated Del: useless -- https://master.php.net/note/delete/115293/useless Del: bad code -- https://master.php.net/note/delete/115293/bad+code Del: spam -- https://master.php.net/note/delete/115293/spam Del: non-english -- https://master.php.net/note/delete/115293/non-english Del: in docs -- https://master.php.net/note/delete/115293/in+docs Del: other reasons-- https://master.php.net/note/delete/115293 Reject -- https://master.php.net/note/reject/115293 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199785) next »