Fixed : “Json Array should begin with [” error on UTF-8 or UTF-16 files

Problem : JSON file which store top level JSON arrays just wouldn’t parse (using org.json library), and gives out an error message like – “Json Array should begin with [ …..”. Editors like Vim or Gedit or IntelliJ show no errors (or any character before “[” )in these files.

Reason :  Byte order marker character is prefixed to the file content (this was probably added when I converted the files from UTF-16 to UTF-8).

Fix:

  1. Open the file in Vim.
  2. Run command-   :set nobomb
  3. save and exit. (:wq)
Kj
Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.

Leave a Comment

Your email address will not be published. Required fields are marked *