0

when I tr to run python manage.py runserver code is giving error . And its traceback is strange ,

I tried

JSON ValueError: Expecting property name: line 1 column 2 (char 1)

and all similar questions but didn't get what exactly I am facing.

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/tousif/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/tousif/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 308, in execute
    settings.INSTALLED_APPS
  File "/home/tousif/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/home/tousif/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/tousif/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/tousif/Desktop/ITP/ITP/itpcrm/itpcrm/settings.py", line 55, in <module>
    cfg = json.loads(open('/home/tousif/Desktop/ITP/ITP/itpcrm/config.json', 'r').read())
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 4 column 1 (char 43)

my config.json file which containt credentials etc (I have changed credentials to post here ) .And got this file from live server where its working fine but on local its giving this error.

{
        "dev": {
                "db": {
​
                        "ENGINE": "django.db.backends.mysql",
                        "NAME": "itpcrm",
                        "USER": "root",
                        "PASSWORD": "password",
                        "HOST": "localhost",
                        "PORT": "3306"
                },
                "jwt_key": "GRESDFwef3452fwefer",
        "voice_api_url": "http://192.112.255.32:9040",
                "voice_api_key": "3123",
        "auth_api_key": "379h4f73f",
        "provisioner_api_key": "abc",
        "quote_approval_url": "http://192.112.255.145:9998/quotes/customer-approval?token=",
        "docusign_base_url": "https://demo.docusign.net/restapi",
        "docusign_integrator_key": "8a256bde-405b",
        "docusign_oauth_base_url": "account-d.docusign.com",
        "docusign_redirect_uri": "http://192.112.255.145:9998/api/callbacks/docusign",
        "docusign_private_key_filename": "/home/itp/docusign-examples/keys/docusign_private_key.txt",
        "docusign_user_id": "7f2444f-ae99-54922fec68f6",
        "docusign_user_name": "dor.com"
        },
        "prod": {
                "db": {
​
                        "ENGINE": "django.db.backends.mysql",
                        "NAME": "itp",
                        "USER": "it",
                        "PASSWORD": "password",
                        "HOST": "192.168.3.111",
                        "PORT": "3306"
                },
                "jwt_key": "rRregrgERg54g564heRGRfdsger",
        "voice_api_url": "https://api.crm.itpscorp.com/itpvoice",
                "voice_api_key": "abc1",
        "auth_api_key": "379h4f73f3279fy927yf928oowqofabdbf",
        "provisioner_api_key": "abc123123",
        "quote_approval_url": "http://192.112.255.145:9998/quotes/customer-approval?token=",
        "docusign_base_url": "https://demo.docusign.net/restapi",
        "docusign_integrator_key": "8a256bde-405b-4032-bf24-be0245631f03",
        "docusign_oauth_base_url": "account-d.docusign.com",
        "docusign_redirect_uri": "http://192.112.255.145:9998/api/callbacks/docusign",
        "docusign_private_key_filename": "/home/itp/docusign-examples/keys/docusign_private_key.txt",
        "docusign_user_id": "7f26f6bb-8a39-444f-ae99-54922fec68f6",
        "docusign_user_name": "docusign@itpfiber.com"
        },
        "mode": "dev"
}
gamer
  • 603
  • 4
  • 20

1 Answers1

2

The empty lines after "db" starts with the unicode codepoint 0x200B ('ZERO WIDTH SPACE'). That is what trips up the JSON decoder.

I copied the text into gvim and made a screenshot. See below.

space in JSON

Remove those characters (or the whole line) and it works...

(Looking at the JSON file with a hex editor would also show the problem clearly.)

If you look closely at the error message, you can that this correctly identifies the problem:

ValueError: Expecting property name: line 4 column 1 (char 43)

The moral of this story: look out for whitespace codepoints.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94