0
votes

I have this code in python 3

import json
with open('calldb.json', 'r') as G:
    data = json.load(G)
    print(data)

and this json file

[
   {
     "n": {
       "identity": 0,
       "labels": [
         "Service",
         "Test"
       ],
       "properties": {
         "name": "Service1",
         "uid": "XD2020",
         "state": "new",
         "type": "internetDualhome"
       }
     }
   },
   {
     "n": {
       "identity": 1,
       "labels": [
         "Test",
         "intpe"
       ],
       "properties": {
         "name": "Pe1",
         "ip": "172.20.20.1/32"
--------skipped lines-----------

those omitted lines are for not sharing the entire file

when i run the program i get this error

raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

what is the problem with this json?

1
Your JSON cuts off and it says "skipped lines". It certainly won't work like that.khelwood

1 Answers

0
votes

Did you add Skipped lines? If you did not add that line, your file is not formatted to be valid JSON.

If you added that line, I would recommend checking your JSON file against a JSON schema. Its possible you do not have a proper bracket or curl in the right spot.

I have used this JSON schema validator in the past and find their syntax to be quite helpful. If you are not sure what version of the schema to select in the drop-down, I recommend defaulting to Draft v4