Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@expo/json-file
Advanced tools
A module for reading, writing, and manipulating JSON files
The @expo/json-file npm package is a utility library for reading and writing JSON files. It provides a simple and convenient API for these operations, handling various edge cases and providing helpful error messages.
Read JSON file
This feature allows you to read a JSON file asynchronously and parse its contents into a JavaScript object.
{"const { readAsync } = require('@expo/json-file');
async function readJsonFile(filePath) {
const json = await readAsync(filePath);
return json;
}
readJsonFile('path/to/file.json').then(data => console.log(data));"}
Write JSON file
This feature enables you to write a JavaScript object to a file as JSON asynchronously, with options to format the output.
{"const { writeAsync } = require('@expo/json-file');
async function writeJsonFile(filePath, data) {
await writeAsync(filePath, data);
}
const data = { key: 'value' };
writeJsonFile('path/to/file.json', data);"}
Modify JSON file
This feature allows you to modify an existing JSON file by providing an object with the modifications you want to apply.
{"const { modifyAsync } = require('@expo/json-file');
async function modifyJsonFile(filePath, modifications) {
await modifyAsync(filePath, modifications);
}
modifyJsonFile('path/to/file.json', { key: 'newValue' });"}
The 'jsonfile' package offers similar functionality to '@expo/json-file' for reading and writing JSON files. It provides methods like 'readFileSync', 'writeFileSync', 'readFile', and 'writeFile'. The main difference is that 'jsonfile' does not provide modification capabilities directly, and it has both synchronous and asynchronous methods.
While 'fs-extra' is a more general file system utility library, it includes methods for reading and writing JSON files, such as 'readJson', 'writeJson', 'readJsonSync', and 'writeJsonSync'. It extends the built-in 'fs' module in Node.js and provides additional file operation methods. It is more comprehensive but less specialized than '@expo/json-file'.
@expo/json-file
A library for reading and writing JSON files.
Install @expo/json-file
in your project.
yarn add @expo/json-file
import JsonFile, { JSONObject } from '@expo/json-file';
// Create a file instance
const jsonFile = new JsonFile<JSONObject>(filePath);
// Interact with the file
await jsonFile.readAsync();
await jsonFile.writeAsync({ some: 'data' });
FAQs
A module for reading, writing, and manipulating JSON files
The npm package @expo/json-file receives a total of 1,674,430 weekly downloads. As such, @expo/json-file popularity was classified as popular.
We found that @expo/json-file demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 28 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.