If your launch script allows you to specify a python target (and finishes quickly enough), you can use pythonArgs in launch.json to insert a shim.

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch via Shell Script",
            "type": "python",
            "pythonArgs": ["debug_shim.py", "launch.sh"],
            "args": ["your", "app", "args"],
            "request": "launch",
            "program": "app.py"
        }
    ]
}

debug_shim.py

import os, subprocess, sys

launcher, debugger, debugger_args = sys.argv[1], sys.argv[2], sys.argv[3:]

sys.exit(subprocess.run(
    args=[launcher] + debugger_args,
    env=dict(os.environ, LAUNCH_TARGET=debugger),
    stdin=sys.stdin,
    stdout=sys.stdout,
    stderr=sys.stderr,
).returncode)

launch.sh

#!/usr/bin/env bash

# Or target could be passed along the command line as well.
# LAUNCH_TARGET="${1?}"

# ...stuff...

python "${LAUNCH_TARGET-app.py}" "${@}"

In my setup of v1.80.0 on WSL2, the debugger call is like so:

python python_args... debugger debugger_args... app app_args...

Then the call stack will be vscode -> shim -> launcher -> debugger -> app and the debugger will connect seamlessly, although if it takes more than several seconds VSCode will time out.

Answer from Merramore on Stack Overflow
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - Learn how to work with JSON data in Python using the json module. Convert, read, write, and validate JSON files and handle JSON data for APIs and storage.
🌐
Reddit
reddit.com › r/vscode › execute a command in the same shell before debugging
r/vscode on Reddit: Execute a command in the same shell before debugging
October 5, 2023 -

Hey everyone,

I want to debug a Python Skript using a different arch (x86_64 instead of arm64) then my default terminal. I was looking for ways to define a terminal profile (see also on stackoverflow) using the launch.json, but I haven't found a way yet. I started trying to use the argument preLaunchTask, but this seems to be executed outside of the terminal (and it also freezes for this specific task). Any ideas how to fix this?

// launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python (x86_64): script.py",
            "type": "python",
            "request": "launch",
            "program": "/path/to/script.py",
            "console": "integratedTerminal",
            "justMyCode": true,
            "preLaunchTask": "x86_64"
        }
    ]
}

//tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "x86_64",
            "type": "shell",
            "command": "arch -x86_64 zsh"
        }
    ]
}
Discussions

Convert script python to .json file
Hello I wrote a scipt in python to detect distance between camera and object, i want to send the distance to an appli node red. Is it possible to convert this script into a .json file and import it into node red to get the readed data into the debug node or into the dashboard ? i've tried to ... More on discourse.nodered.org
🌐 discourse.nodered.org
1
0
August 7, 2021
How do I run a Python script on a set of JSON files? - Stack Overflow
I am writing a script that takes 2 JSON files which will just be a basic object of key/value pairs and compare the lengths of the files (number of keys) and well as if the keys are matching. I will... More on stackoverflow.com
🌐 stackoverflow.com
Help with a script to grab JSON data embedded in <script> tags
If the data you want to extract is in script tag, then I am guessing the website is using Javascript to populate those data. I think you can also give it a go with selenium library which is designed to perform browser automation. In selenium, there is a function to execute Javascript code. So if for example the json data is stored in a variable, you can use selenium function "execute_script" to return the Javascript variable or Javascript function. More on reddit.com
🌐 r/learnpython
2
2
January 13, 2022
(absolute beginner) how do I run a Python script & how do I edit JSON?
Hi guys, This is properly easy to do but i have no idea how to do it. So I downloaded something from GitHub that is supposed to help me find codes on a websites. The instructions are following: After running edit: $HOME/.config/crunchyroll-guest-pass-finder/accounts.json The JSON file is an ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
June 20, 2020
Top answer
1 of 4
2

If your launch script allows you to specify a python target (and finishes quickly enough), you can use pythonArgs in launch.json to insert a shim.

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch via Shell Script",
            "type": "python",
            "pythonArgs": ["debug_shim.py", "launch.sh"],
            "args": ["your", "app", "args"],
            "request": "launch",
            "program": "app.py"
        }
    ]
}

debug_shim.py

import os, subprocess, sys

launcher, debugger, debugger_args = sys.argv[1], sys.argv[2], sys.argv[3:]

sys.exit(subprocess.run(
    args=[launcher] + debugger_args,
    env=dict(os.environ, LAUNCH_TARGET=debugger),
    stdin=sys.stdin,
    stdout=sys.stdout,
    stderr=sys.stderr,
).returncode)

launch.sh

#!/usr/bin/env bash

# Or target could be passed along the command line as well.
# LAUNCH_TARGET="${1?}"

# ...stuff...

python "${LAUNCH_TARGET-app.py}" "${@}"

In my setup of v1.80.0 on WSL2, the debugger call is like so:

python python_args... debugger debugger_args... app app_args...

Then the call stack will be vscode -> shim -> launcher -> debugger -> app and the debugger will connect seamlessly, although if it takes more than several seconds VSCode will time out.

2 of 4
2

Adding the setup scripts to your .bashrc file will ensure that they are sourced before vscode begins debugging your program. The ROS2 documentation supports this method and provides an example.

In your .bashrc file add the following:

source /opt/ros/${ROS_DISTRO}/setup.bash
source ~/ros2_ws/install/local_setup.bash
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Python Debugger: Debug Python File.
🌐
Medium
medium.com › analytics-vidhya › js-meet-python-i-am-json-f0300db8d68f
JS, meet Python — I am JSON.
November 14, 2019 - The purpose of the above Python script is to test out our API. For some reason it takes a while, but it’s mostly for debugging and test. The JavaScript portion is where the work is being done on D3.js, so we need to be smart about our request. Before diving into the JavaScript request to our app, start by understanding JavaScript Promises.
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging
Debug code with Visual Studio Code
November 3, 2021 - For more complex debugging scenarios like attaching to a running process, you need to create a launch.json file to specify the debugger configuration. Get more information about debug configurations. Choose the debugger you want to use from the list of available debuggers. VS Code tries to run and debug the currently active file. For Node.js, VS Code checks for a start script in the package.json file to determine the entry point of the application.
🌐
Halo Lab
halo-lab.com › blog › how-to-run-a-python-script-from-node-js
How to Run a Python script from Node.js | Halo Lab
April 12, 2023 - Of course you can always build API on top of Python backend (Flack, etc), but in that case you need to build, host and manage one more application, when you just need to run a single Python script. That's why I want to give you step by step instructions on how to achieve this. ... To begin with, let's briefly define what are both languages. Node.js is a server-side platform developed on Google Chrome’s JavaScript Engine.
Find elsewhere
🌐
Node-RED
discourse.nodered.org › general
Convert script python to .json file - General - Node-RED Forum
August 7, 2021 - Hello I wrote a scipt in python to detect distance between camera and object, i want to send the distance to an appli node red. Is it possible to convert this script into a .json file and import it into node red to get the readed data into the debug node or into the dashboard ? i've tried to exec the script automatically in node red but it didn"t work Thanks.
🌐
Stack Overflow
stackoverflow.com › questions › 72594348 › how-do-i-run-a-python-script-on-a-set-of-json-files
How do I run a Python script on a set of JSON files? - Stack Overflow
I put together a Repl to demonstrate what I'm trying to do: https://replit.com/@AlexWhitmore/python-stuff?v=1 ... In return_func_settings, you loop over func_files but overwrite app_settings at each iteration, so you're discarding everything you read except the last file. ... you should have two object where one object contain the config file where other object have json file.
🌐
MakeUseOf
makeuseof.com › home › programming › how to get python and javascript to communicate using json
How to Get Python and JavaScript to Communicate Using JSON
February 12, 2022 - from flask import Flask, request, jsonify from flask_cors import CORS <strong>#Set up Flask</strong>: app = Flask(__name__) <strong>#Set up Flask to bypass CORS</strong>: cors = CORS(app) <strong>#Create the receiver API POST endpoint</strong>: @app.route("/receiver", methods=["POST"]) def postME(): data = request.get_json() data = jsonify(data) return data if __name__ == "__main__": app.run(debug=True) Since the POST API endpoint is ready, create a JavaScript and HTML file in your project root folder (where your flask app is). Give them any name you like (data.js and index.html in this case). ... <!DOCTYPE html> <html> <head> <title> Python sending </title> </head> <body> <button id="theButton">Post to Python</button> <h3 id = "info"></h3> <strong><!-- Link to the JavaScript file here: --></strong> <script src="data.js"></script> </body> </html>
🌐
Python
docs.python.org › 3 › library › json.html
JSON encoder and decoder — Python 3.14.3 documentation
February 23, 2026 - Source code: Lib/json/__init__.py JSON (JavaScript Object Notation), specified by RFC 7159(which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript...
🌐
Reddit
reddit.com › r/learnpython › help with a script to grab json data embedded in tags
r/learnpython on Reddit: Help with a script to grab JSON data embedded in <script> tags
January 13, 2022 -

I'm engaged in a scraping project, and I've been struggling to get JSON data out of script tags. BeautifulSoup is getting the script tag and its contents just fine, but I'm uncertain of anything that works to parse the JSON out cleanly. Using regex has not been super effective, and I've run into problems with it. Based on what I could find, that's probably more an issue with my regex knowledge.

I coded up the below based on the idea that I can step through a string, index the point when a JSON block probably starts, count the degree of nesting (with the depth variable) and index the point when I come out of the block when depth returns to 0, then pass this slice to json.loads. The output is then passed to a list and returned.

It seems to work based on limited testing, but I don't want to abuse the website just to test if this will work effectively. I feel happy that I've gotten this far, but my use of the first few if/elif statements feels janky and crap, and the size of the JSON blocks are just too huge to really read manually to check if I'm getting anything wrong.

My questions are:

  • is there a better way to manage the flow control with the first few while/if/elif statements?

  • is there a library that will do this for me?

  • would regex actually be easier, and if so, what would work?

  • am I likely to run into any data parsing problems with the below code?

Notes on the scraped website: the website often uses <script> to hold JSON data, or a mix of JS and JSON, sometimes just JS, sometimes it holds a src link to another page with no other content. The JSON itself is properly formatted, but it may not sit in the script tag cleanly, and sometimes there are multiple blocks with non-JSON content in between. There will be some ~15 script tags per page, but this varies. The script content will have a character length of 100000 on average, but ranges between 0-200000. Sometimes they are tagged appropriately as JSON data, but often not.

def JSON_extr(incoming):
    # various pointers
    index = 0 # will act as starting point for incrementing the string.find function
    depth = 0 # will track the degree of depth
    pointer = 0 # pointer for tracking location w/in string segment
    first = True # switches to False while inside a JSON block
    json_lists = []
    finalising = False # sets to True when no {" remain
    
    while (('{"' in incoming[index:]) or ('}' in incoming[index:])): 
        # while there is something left to find
        brack_open = incoming[index:].find('{"')
        brack_clos = incoming[index:].find('}')
        
        if not ('{"' in incoming[index:]): 
            # sets later functions to resolve remaining 
            finalising = True
            
        if -1 < brack_open < brack_clos: 
            # negative will indicate none left, and cause a bug
            pointer = brack_open
            depth +=1
        elif ((brack_clos < brack_open) or finalising): 
            # finalising kicks if there are no {"s left;
            # otherwise brack_clos will always be lower
            pointer = brack_clos
            depth -=1
            
        if first == True: # if starting a JSON block, keep a note of the index
            first = False
            start = pointer+index
            
        if depth <= 0: # if we return out of the block, assess data as JSON
            packet = incoming[start:(index+pointer+1)]
            if packet:
                try: # try to convert to json; if it fails, report warnings
                    json_lists.append(json.loads(packet))
                except json.JSONDecodeError as e:
                    if start == index+pointer:
                        pass # empty parentheses
                    else:
                        warnings.warn(f"Possible JSON candidate between indexes {start}:{index+pointer+1} failed with {e}")
            first = True # reset the possibility of another JSON block
            if depth <0:
                warnings.warn(f'Nesting error in found, resetting nesting depth to zero.')
                depth = 0
        index +=(pointer+1)
        counter +=1
    return json_lists

Really appreciate any help with this!

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
(absolute beginner) how do I run a Python script & how do I edit JSON? - JavaScript - The freeCodeCamp Forum
June 20, 2020 - Hi guys, This is properly easy to do but i have no idea how to do it. So I downloaded something from GitHub that is supposed to help me find codes on a websites. The instructions are following: After running edit: $HOME/.config/crunchyroll-guest-pass-finder/accounts.json The JSON file is an array of dictionaries containing the following fields Fields are: Username - username of the account Password - password of the account Active (optional) - if set and false, then the account is ignor...
🌐
Better Stack
betterstack.com › community › guides › scaling-nodejs › json-data-in-python
Working With JSON Data in Python | Better Stack Community
This guide shows you how to handle JSON in your Python applications. You'll learn everything from basic conversion to advanced validation techniques. ... Better Stack lets you see inside any stack, debug any issue, and resolve any incident. Explore more · Before starting, ensure that you have Python 3.7 or a later version installed.
🌐
Medium
medium.com › letsboot › visual-studio-code-node-debugging-package-json-launch-json-source-env-sh-d14294e98293
Visual Studio Code — Node Debugging — package.json, launch.json, source env.sh | by Jonas Felix | letsboot | Medium
November 24, 2018 - To run debugging with this environment variables in Visual Studio Code I use the npm debug script. (No I really don’t want to put environment variables in launch.json or task.json :-)…) ... Full Stack JavaScript development.
🌐
Our Code World
ourcodeworld.com › articles › read › 286 › how-to-execute-a-python-script-and-retrieve-output-data-and-errors-in-node-js
How to execute a Python script and retrieve output (data and errors) in Node.js | Our Code World
October 25, 2016 - To send data from Javascript to our Python script, we need to write text using the standard input (stdin) in the process. In this example, we are going to send an array (in string format using the JSON.stringify method) to Python:
🌐
JetBrains
jetbrains.com › guide › python › tips › run-npm-scripts
Run npm Scripts from package.json - JetBrains Guide
October 20, 2024 - Browse your package.json scripts and run in a dedicated tool window.
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
When you convert from Python to JSON, Python objects are converted into the JSON (JavaScript) equivalent:
🌐
GitHub
github.com › microsoft › vscode-python-debugger › issues › 142
Debugging an active python file that creates launch.json is debugging launch.json · Issue #142 · microsoft/vscode-python-debugger
November 28, 2023 - Make sure that you don't have a launch.json config already set. On the top right you will see a play button with an arrow, click the arrow and then click: Python Debugger: Debug using launch.json
Author   sandy081