0

I want to make a Python script that transforms a part of VS Code launch.json into a normal command for a terminal. I need it to communicate with non-VSCode users. Here is the example:

import json launch_json = ''' { "name": "temp", "type": "python", "request": "launch", "program": "script.py", "console": "integratedTerminal", "justMyCode": false, "args": ["abcd", "--log", "log.txt"], "env": {"CUDA_VISIBLE_DEVICES":"0"}, } ''' d = json.loads(launch_json) command = d["program"] + " " + " ".join(d["args"]) print(command) 

If I run it, I have the following error:

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 12 column 9 (char 344) 

How do I make the script?

1
  • Remove the trailing comma on the last property value (env) Commented Aug 4, 2022 at 10:52

1 Answer 1

1

There is an extra comma at the end of launch_json

{ "env": {"CUDA_VISIBLE_DEVICES":"0"}, <- should not be here } 

so just replace it with

{ "name": "temp", "type": "python", "request": "launch", "program": "script.py", "console": "integratedTerminal", "justMyCode": false, "args": ["abcd", "--log", "log.txt"], "env": {"CUDA_VISIBLE_DEVICES":"0"} } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.