Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

python - 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:solr640contribltrexample>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:UsersPankajAppDataLocalProgramsPythonPython36-32libjson\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjson\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjsondecoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjsondecoder.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...