Socket
Socket
Sign inDemoInstall

@expo/json-file

Package Overview
Dependencies
17
Maintainers
27
Versions
88
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @expo/json-file

A module for reading, writing, and manipulating JSON files


Version published
Weekly downloads
1.3M
increased by6.23%
Maintainers
27
Install size
500 kB
Created
Weekly downloads
 

Package description

What is @expo/json-file?

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.

What are @expo/json-file's main functionalities?

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' });"}

Other packages similar to @expo/json-file

Readme

Source

👋 Welcome to
@expo/json-file

A library for reading and writing JSON files.

🏁 Setup

Install @expo/json-file in your project.

yarn add @expo/json-file

⚽️ Usage

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' });

Keywords

FAQs

Last updated on 15 Apr 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc