Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

json reading error json.decoder.JSONDecodeError: Invalid \escape

I am writing a code to upload a model (train_and_upload_demo_model.py) in solr using "config.json" file settings. but I am getting following error:

json.decoder.JSONDecodeError: Invalid \escape: line 11 column 34 (char 461)

this is the traceback:

D:\solr640\contrib\ltr\example>python train_and_upload_demo_model.py -c config.json

Traceback (most recent call last):
  File "train_and_upload_demo_model.py", line 182, in <module>
    sys.exit(main())
  File "train_and_upload_demo_model.py", line 158, in main
    config = json.load(configFile)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 11 column 34 (char 461)

content of config.json file

  {
    "host":                     "localhost",
    "port":                     8983,
    "collection":               "techproducts",
    "requestHandler":           "query",
    "q":                        "*:*",
    "efiParams":                "efi.user_query='$USERQUERY'",
    "userQueriesFile":          "user_queries.txt",
    "trainingFile":             "exampleTrainingFile.txt",
    "trainedModelFile":         "exampleTrainedModel.txt",
    "trainingLibraryLocation":  "D:\liblinear-2.11",
    "trainingLibraryOptions":   "-q",
    "solrFeaturesFile":         "exampleFeatures.json",
    "solrFeatureStoreName":     "exampleFeatureStore",
    "solrModelFile":            "exampleModel.json",
    "solrModelName":            "exampleModel"
  }

can i get to know where i am making the mistake?

Is this is the error because of "trainingLibraryLocation": "D:\liblinear-2.11", syntax?? because this is the line no. 11

Is there any other way to pass directory location.

like image 739
pankaj kashyap Avatar asked Jun 21 '17 23:06

pankaj kashyap


1 Answers

The \l in "trainingLibraryLocation": "D:\liblinear-2.11" is treated like an escape sequence. Try escaping the slash itself, ie. "D:\\liblinear-2.11".

like image 144
SpaceBison Avatar answered Sep 18 '22 10:09

SpaceBison