
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
json-to-python
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
Simple utility to convert JSON to Python TypedDict or dataclass.
Try it out: json-to-python Playground
As an engineer who appreciates types and works extensively with Python, especially in the realm of AI development, I often encounter the need to communicate with external APIs, like calling a vector database server's API. In cases where an official SDK is not provided, I have to handle the API calls manually. I strongly prefer using types for requests and responses, and I found myself needing an easy way to convert JSON to TypedDict. Not finding a suitable solution, I decided to implement this utility myself.
This library can be executed in a browser, through the CLI, or used as a library.
To execute in a browser, please use the json-to-python Playground.
To execute via CLI, use the following command:
npx json-to-python <json-dir> <output-dir>
npx json-to-python <json-dir> <output-dir> --casing <camel|snake|none> --generate <typeddict|dataclass>
To use this repository as a library, first, install this repository:
npm install json-to-python
Single JSON Conversion
import { generate } from "json-to-python/browser";
const jsonString = JSON.stringify({ name: "Mr X", age: 30, city: "New York" });
const className = "Main";
const config = {
casing: "camel",
generate: "typeddict",
};
const python = generate(jsonString, className, config);
Folder Conversion
import { bulkGenerate } from "json-to-python";
const config = {
casing: "camel",
generate: "typeddict",
};
const python = bulkGenerate(
"./path_to_input_dir",
"./path_to_output_dir",
config
);
Please see ./packages/json-to-python/CHANGELOG.md
If you find a bug or have a new feature request, please feel free to open an issue. Pull requests are also welcome.
FAQs
Simple utility to convert JSON to Python TypedDict or dataclass
The npm package json-to-python receives a total of 117 weekly downloads. As such, json-to-python popularity was classified as not popular.
We found that json-to-python demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.