title: PHP json_decode() returns NULL with valid JSON?
body: <p>I have this JSON object stored on a plain text file:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;MySQL&quot;: {
          &quot;Server&quot;: &quot;(server)&quot;,
          &quot;Username&quot;: &quot;(user)&quot;,
          &quot;Password&quot;: &quot;(pwd)&quot;,
          &quot;DatabaseName&quot;: &quot;(dbname)&quot;
      },
      &quot;Ftp&quot;: {
          &quot;Server&quot;: &quot;(server)&quot;,
          &quot;Username&quot;: &quot;(user)&quot;,
          &quot;Password&quot;: &quot;(pwd)&quot;,
          &quot;RootFolder&quot;: &quot;(rf)&quot;
      },
      &quot;BasePath&quot;: &quot;../../bin/&quot;,
      &quot;NotesAppPath&quot;: &quot;notas&quot;,
      &quot;SearchAppPath&quot;: &quot;buscar&quot;,
      &quot;BaseUrl&quot;: &quot;http:\/\/montemaiztusitio.com.ar&quot;,
      &quot;InitialExtensions&quot;: [
          &quot;nem.mysqlhandler&quot;,
          &quot;nem.string&quot;,
          &quot;nem.colour&quot;,
          &quot;nem.filesystem&quot;,
          &quot;nem.rss&quot;,
          &quot;nem.date&quot;,
          &quot;nem.template&quot;,
          &quot;nem.media&quot;,
          &quot;nem.measuring&quot;,
          &quot;nem.weather&quot;,
          &quot;nem.currency&quot;
      ],
      &quot;MediaPath&quot;: &quot;media&quot;,
      &quot;MediaGalleriesTable&quot;: &quot;journal_media_galleries&quot;,
      &quot;MediaTable&quot;: &quot;journal_media&quot;,
      &quot;Journal&quot;: {
          &quot;AllowedAdFileFormats&quot;: [
              &quot;flv:1&quot;,
              &quot;jpg:2&quot;,
              &quot;gif:3&quot;,
              &quot;png:4&quot;,
              &quot;swf:5&quot;
          ],
          &quot;AdColumnId&quot;: &quot;3&quot;,
          &quot;RSSLinkFormat&quot;: &quot;%DOMAIN%\/notas\/%YEAR%-%MONTH%-%DAY%\/%TITLE%/&quot;,
          &quot;FrontendLayout&quot;: &quot;Flat&quot;,
          &quot;AdPath&quot;: &quot;ad&quot;,
          &quot;SiteTitle&quot;: &quot;Monte Maíz: Tu Sitio&quot;,
          &quot;GlobalSiteDescription&quot;: &quot;Periódico local de Monte Maíz.&quot;,
          &quot;MoreInfoAt&quot;: &quot;Más información aquí, en el Periódico local de Monte Maíz.&quot;,
          &quot;TemplatePath&quot;: &quot;templates&quot;,
          &quot;WeatherSource&quot;: &quot;accuweather:SAM|AR|AR005|MONTE MAIZ&quot;,
          &quot;WeatherMeasureType&quot;: &quot;1&quot;,
          &quot;CurrencySource&quot;: &quot;cotizacion-monedas:Dolar|Euro|Real&quot;,
          &quot;TimesSingular&quot;: &quot;vez&quot;,
          &quot;TimesPlural&quot;: &quot;veces&quot;
      }
  }
  </code></pre>
  <p>When I try to decode it with <code>json_decode()</code>, it returns NULL. Why?
  The file is readable (I tried echoing <code>file_get_contents()</code> and it worked ok).</p>
  <p>I've tested JSON against <a href="http://jsonlint.com/" rel="noreferrer">http://jsonlint.com/</a> and it's perfectly valid.</p>
  <p>What's wrong here?</p>
  <h1>Update (response valid to my 2010 problem)</h1>
  <p>Looking for answers on Google, I got back to SO: <a href="https://stackoverflow.com/questions/689185/json-decode-returns-null-php">json_decode returns NULL after webservice call</a>. My JSON file had the UTF BOM sequence (some binary chars that shouldn't be there), thus, breaking the JSON structure. Went to Hex Editor, erased the bytes. Everything's back to normal.
  Why has this happened? <em>Because I edited the file using Microsoft Windows' Notepad.</em> Terrible idea!</p>