🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@helixnetwork/extract-json

Package Overview
Dependencies
Maintainers
16
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helixnetwork/extract-json

Extracts JSON encoded messages from signature message fragments

latest
Source
npmnpm
Version
1.0.0-alpha.7
Version published
Maintainers
16
Created
Source

@helixnetwork/extract-json

Extracts JSON encoded messages from signature message fragments.

Installation

Install using npm:

npm install @helixnetwork/extract-json

or using yarn:

yarn add @helixnetwork/extract-json

API Reference

<a name="module_extract-json..extractJson"></a>

extract-json~extractJson(bundle)

ParamType
bundlearray

Takes a bundle as input and from the signatureMessageFragments extracts the correct JSON data which was encoded and sent with the transaction. Supports the following forms of JSON encoded values:

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

Example

try {
  const msg = JSON.parse(extractJson(bundle))
} catch (err) {
  err.msg == errors.INVALID_BUNDLE
  // Invalid bundle or invalid encoded JSON
}

Example
Example with getBundle:

getBundle(tailHash)
  .then(bunlde => {
     const msg = JSON.parse(extractJson(bundle))
     // ...
  })
  .catch((err) => {
     // Handle network & extraction errors
  })

Keywords

helix

FAQs

Package last updated on 24 Sep 2019

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