Socket
Socket
Sign inDemoInstall

jsconv

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsconv

Convert Javascript Data to Python through JSON files


Version published
Maintainers
1
0

Weekly downloads

Readme

Source

jsconv

A Library to convert Javascript data to Python through JSON files. Read, Write, and Update data using Jsconv, which can be read through Python scripts.

Installation and use

Prerequisite:

Install jsconv:

npm install jsconv

Importing Jsconv to your Program

const { jsconv_init } = require('jsconv')

Full npm script reference

Initialization

To begin using jsconv, it is essential that you initialize a filepath of the desired json file to read, write, and update data. This can be done so with the following syntax:

const jsconv_var = jsconv_init('FILEPATH_OF_JSON')

Note: If the filepath is not in string format an error will be thrown. View the Errors section of the documentation to learn more.

Reading JSON data

Jsconv returns all data from json in the form of a dictionary with the following syntax:

const returned_data = jsconv_var.readjs()

Note: Filepath must be valid or an error will be prompted.

Jsconv will return null if there is no data on the json file.

Writing to JSON

Write data to JSON in the form of a key, value pair as so:

jsconv_var.writejs('KEY', 'VAL')

If the key has not been used to store data in the json, a new entry will appear on the file. However, if the key has already been used, the new data will override the old data by nature of a dictionary.

Note: Errors may appear if the filepath is specified incorrectly upon initialization. Learn more under the Errors section of the documentation.

Load a certain Key on JSON

Jsconv has the ability to load a certain value given a desired key in the JSON.

const specific_data = jsconv_test.loadjs('KEY')

If the key is not found, an error will be prompted. Moreover, if the key has an empty data value, jsconv will return an undefined or null.

Errors

The most common error that can occur is a native JSON error where the filepath cannot be found in the form of:

SyntaxError: Unexpected end of JSON input

In this case, it is essential that the user has the filepath specified in the string format and is correct in terms of location. A common mistake users have is that they do not place, ./ before the parent directory to indicate that the location is within our present directory location on the Operating System.

Other errors that revolve JSON files are mostly related to its location. It is absolutely essential that the filepath is correct as all functions part of jsconv require a filepath reference.

Resources (Coming Soon)

  • Pypi pconv
  • Jsconv npm

Contact Information

Here are some of the ways you can find me:

Made by @Jaival - 2022

Keywords

FAQs

Last updated on 06 Aug 2022

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