
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
@codemod-utils/json
Advanced tools
Utilities for handling JSON
@codemod-utils/json
helps you update files like package.json
and tsconfig.json
.
Converts an object to a Map. The Map
data structure helps you add, update, and remove entries.
import { convertToMap } from '@codemod-utils/json';
function updateDependencies(packageJson) {
const dependencies = convertToMap(packageJson['dependencies']);
const packagesToDelete = [
'@embroider/macros',
'ember-auto-import',
'ember-cli-babel',
'ember-cli-htmlbars',
];
packagesToDelete.forEach((packageName) => {
dependencies.delete(packageName);
});
}
Converts a Map (back) to an object. convertToObject
helps you update the JSON.
import { convertToMap, convertToObject } from '@codemod-utils/json';
function updateDependencies(packageJson) {
const dependencies = convertToMap(packageJson['dependencies']);
const packagesToDelete = [
'@embroider/macros',
'ember-auto-import',
'ember-cli-babel',
'ember-cli-htmlbars',
];
packagesToDelete.forEach((packageName) => {
dependencies.delete(packageName);
});
packageJson['dependencies'] = convertToObject(dependencies);
}
Reads package.json
and returns the parsed JSON.
import { readPackageJson } from '@codemod-utils/json';
const { dependencies, devDependencies } = readPackageJson({
projectRoot: '__projectRoot__',
});
const projectDependencies = new Map([
...Object.entries(dependencies ?? {}),
...Object.entries(devDependencies ?? {}),
]);
const hasTypeScript = projectDependencies.has('typescript');
readPackageJson
checks that package.json
exists and is a valid JSON. Call validatePackageJson
if you need to know that the name
and version
fields exist.
import { readPackageJson, validatePackageJson } from '@codemod-utils/json';
const packageJson = readPackageJson({
projectRoot: '__projectRoot__',
});
validatePackageJson(packageJson);
const { name, version } = packageJson;
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Utilities for handling JSON
The npm package @codemod-utils/json receives a total of 364 weekly downloads. As such, @codemod-utils/json popularity was classified as not popular.
We found that @codemod-utils/json demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.