1.0.0-alpha.7 • Published 6 years ago
@helixnetwork/extract-json v1.0.0-alpha.7
@helixnetwork/extract-json
Extracts JSON encoded messages from signature message fragments.
Installation
Install using npm:
npm install @helixnetwork/extract-jsonor using yarn:
yarn add @helixnetwork/extract-jsonAPI Reference
<a name="module_extract-json..extractJson"></a>extract-json~extractJson(bundle)
| Param | Type |
|---|---|
| bundle | array |
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
})1.0.0-alpha.7
6 years ago
1.0.0-alpha.6
6 years ago
1.0.0-alpha.5
6 years ago
1.0.0-alpha.4
6 years ago
1.0.0-alpha.3
6 years ago
1.0.0-alpha.2
6 years ago
1.0.0-alpha.1
7 years ago
1.0.0-alpha.0
7 years ago
0.0.1-alpha.1
7 years ago