json reading error json.decoder.JSONDecodeError: Invalid \escape
Asked Answered
L

1

13

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.

Lout answered 21/6, 2017 at 23:1 Comment(1)
So you can pinpoint your problem by replacing that string with a version without "D:\" an execute your code again.Diluvial
M
13

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

Moia answered 22/6, 2017 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.