Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iota/extract-json

Package Overview
Dependencies
Maintainers
6
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iota/extract-json

Extracts JSON encoded messages from signature message fragments

  • 1.0.0-beta.30
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-16.67%
Maintainers
6
Weekly downloads
 
Created
Source

@iota/extract-json

Extracts JSON encoded messages from signature message fragments.

Installation

Install using npm:

npm install @iota/extract-json

or using yarn:

yarn add @iota/extract-json

API Reference

extract-json.extractJson(bundle)

Summary: Extracts JSON from transactions.
Throws:

  • errors.INVALID_BUNDLE : Make sure that the bundle argument is an array of transaction trytes.
  • errors.INVALID_JSON : Make sure that the transactions' signatureMessageFragment fields contain valid JSON.
ParamTypeDescription
bundlearrayTransaction trytes

This method takes the signatureMessageFragment fields of all the given transaction trytes, and tries to extract any JSON data that's in them.

The following forms of JSON-encoded values are supported:

  • "{ \"message\": \"hello\" }"
  • "[1, 2, 3]"
  • "true", "false" & "null"
  • "\"hello\""
  • 123

To get a bundle's transaction trytes from the Tangle, use the getBundle() method.

Returns: string | number | null - The JSON data in the transactions
Example

try {
  const json = JSON.parse(extractJson(bundle))
} catch (error) {
  console.log(error);
}

Keywords

FAQs

Package last updated on 18 Jun 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc