JSON Parse Error in Windows Sensu Client Powershell Setup Script – unexpected character at line 1, column 1

I am creating a install script for Sensu on Windows and am getting this error upon starting the service:

{
  "timestamp": "2016-04-14T23:05:45.043371+0100",
  "level": "warn",
  "message": "config file must be valid json",
  "file": "C:/opt/sensu/conf.d/client.json",
  "error": "unexpected character at line 1, column 1 [parse.c:652]"
}

This error is given on all JSON config files.

Here is my install script which successfully installs the msi and writes the files how I want them: http://pastebin.com/GgQsNcAX

Here is an example of a config file it output:

{
    "client": {
        "name": "Server1",
        "address": "1.1.1.1",
        "subscriptions": [ "none" ]
    }
}

Symbols:

JSON CRLF Symbols

Looks fine to me !?

Answer

Suggestion: Use a hex editor to look at the file. You may find a rogue FE FF at the file head; this is a byte order marker for Unicode, and does not show in Unicode-aware text editors. Notepad, by the way, is Unicode-aware. (You’ll also find, in this case, that your curly brace instead of being 0x7B, is actually 0x00 0x7B.)

Attribution
Source : Link , Question Author : ZZ9 , Answer Author : CharlesW

Leave a Comment